Home » Infrastructure » Linux » executing commands on other users using SU
executing commands on other users using SU [message #179697] Wed, 28 June 2006 08:13 Go to next message
ashosheh
Messages: 25
Registered: June 2006
Location: JOR
Junior Member
hello guys.
i'm trying to execute a batch on another linux user, i used the command su <username> -c "<command to run>"
but nothing happens when i run this command (no errors no warnings), note that the file has 777 permissions, and when i run this command from current user it succeeds.
the command i'm trying to run is:
------------------------------------------
linux> su myuser -c "/envfile /batch.exe"
------------------------------------------

but when I write:
----------------------------------------
linux> ./batch.exe
----------------------------------------
everything goes fine.

note: (envfile) is a file I created is similar to (.profile) and it exports environment variables to the other user.

Re: executing commands on other users using SU [message #179721 is a reply to message #179697] Wed, 28 June 2006 08:56 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>linux> su myuser -c "/envfile /batch.exe"
I suspect a couple of "details" are not as they should be in the above line.
1) as specified the files would have to reside in the "root" (/) folder.
2) multiple commands on the same line are separated by a semicolon ";".
$ su myuser -c "./envfile;./batch.exe" might worked better; then again might not
HTH & YMMV
Previous Topic: Memory Usage riched 100%
Next Topic: cannot conect at port 115 to implement standard RFC913
Goto Forum:
  


Current Time: Thu Apr 18 12:03:59 CDT 2024