Discussion Locked

script in UNIX

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I loged in as user:
user: tif , group: other ,

in terminal console I switched user: "su"
user: root group: other

Then I created a script: "move" -wrxwrxwrx
but when start this script "source move" I see message "Can't find move"

Why I can't run script under different user name
even if we are in same group?

5 replies

by gary_w

i assume you created the 'move' script in the current directory. The current directory must not be in your search path when su'd to root. Test this by using the 'which' command, as in:
$ which move

You can always run it by forcing the shell to look in the current directory:
$ ./move

Note adding the current directory to your search path is dangerous and a security hole. A dubious person who gained access to your account could make a script with the same name as a standard utility like 'ls' and put it in your current directory. When you innocently typed 'ls', the dubious script could wreak some havoc, then call the real 'ls', then delete itself.

Gary

by ghislain.levesque

"." is not part of your default PATH. It's a security hole, but if you still want to do it, at least put it at the end of the PATH variable.
You should not write script with the same name as an unix command. Just to avoid confusion. You should create a directory like /usr/local/bin and put your script there and add it to the PATH.

You should never put 777 as permission for a script, that way anyone could modify your script, 750 or 755 is much better.

This discussion is closed to new replies.