Jump to content

question about script permissions [solved]


Recommended Posts

I have two bash scripts address and trimlogs. Their permissions are as follows:

 

-rwxrwxr-x 1 root adm 443 Dec 18 08:33 address*

 

-rwxrwxr-x 1 root adm 395 Oct 5 06:03 trimlogs*

 

trimlogs

was stolen from somewhere here on MUB

it is used to trim /var/log/messages

I have set up a shortcut using Menu Editor to run this script as root, works fine

 

address

determines my current IP address using ifconfig

it works fine from the console using su

I have set up a shortcut using Menu Editor to run this script as root, it doesn't work: ifconfig: command not found

 

I'm sure my newbness is showing, how come?? :wall:

Link to comment
Share on other sites

I have set up a shortcut using Menu Editor to run this script as root, it doesn't work: ifconfig: command not found

 

I'm sure my newbness is showing, how come??  :wall:

"su" does several things, the following being among them :

- change real/effective user ID

- source bashrc / bash_profile / etc for the new user

I suspect that "run as root" mechanism of the menu does only the first thing and not the second, and the script runs with ID of root but with a regular user's environment, including the PATH variable. Now, "ifconfig" is located in "/sbin", which is never included by default into a regular user PATH.

So, here are two "quick and dirty" solutions :

- put the following line at the beginning of the script :

export PATH=/sbin:$PATH

 

- replace "ifconfig" with "/sbin/ifconfig"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...