AIX script hangs when using /dev/null > 2>&1

786 views Asked by At

I am trying to run a script in AIX to execute another script on a remote server. In addition to the remote script i need to send the stdout to /dev/null. The same command works fine on another server but when I run on the current server it hangs, any advice?

su - test -c "rsh testserver /scripts/testme" 2>&1 >/dev/null1

1

There are 1 answers

1
Walter A On

In your comment you write that a menu is presented when the user logins.
Let's say this is done in the .profile file, using echoes and a read command.
When a menu is presented, the read command in the menu code will not be skipped by redirecting the output. The menu still waits for your input and the su command seems to hang.

Can you change your .profile or .bashrc so that it will skip presenting the menu when called using a su command? When this is called during startup, you can look at the returncode of tty. When you use the su command from the commandline, you should look for another solution. When your root shell is ksh, you can try the following:

if [[ "$(ps -fp $$)" != *"-ksh -c "* ]]; then
   echo "Now I should call the Menu"
fi