daniewicz Posted December 18, 2005 Report Share Posted December 18, 2005 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?? Quote Link to comment Share on other sites More sharing options...
chalex20 Posted December 18, 2005 Report Share Posted December 18, 2005 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?? <{POST_SNAPBACK}> "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" Quote Link to comment Share on other sites More sharing options...
daniewicz Posted December 18, 2005 Author Report Share Posted December 18, 2005 - replace "ifconfig" with "/sbin/ifconfig" :D Thank you very much chalex20. This works! Quote Link to comment Share on other sites More sharing options...
chalex20 Posted December 18, 2005 Report Share Posted December 18, 2005 I hope that my explanation of the reasons why this should work, was not very confusing, and that you did understand what the problem really was, and not just used the solution :-) Quote Link to comment Share on other sites More sharing options...
daniewicz Posted December 18, 2005 Author Report Share Posted December 18, 2005 I understand why your fixed worked B) Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.