0

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

Val Marinov
  • 2,705
  • 17
  • 22
dnl
  • 1
  • 1
  • First try without su... also rsh is outdated, use ssh: ssh testserver 'sh -xv /scripts/exec >/tmp/remote.log.$$ 2>&1' – Zsigmond Lőrinczy Sep 17 '15 at 17:31
  • thanks for the suggestion. this works fine, but i need to run as another user. Also i need the /dev/null to suppress the menu that is set for the particular user and just run the script. to clarify: normally the user would log in and be presented with a menu of three options. i need to suppress this and run the script – dnl Sep 18 '15 at 12:41
  • That's cool, but you still have to go step-by-step to find the problem. Use log/debug/verbose options gratiously; if you want to redirect output, redirect it to a file, not /dev/null. You might want to try using ssh-option -T/-n if you don't want interaction with the remote script. – Zsigmond Lőrinczy Sep 19 '15 at 17:59

1 Answers1

0

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
Walter A
  • 19,067
  • 2
  • 23
  • 43
  • thanks for your answer, i will give it a try. but i managed to sort out the issue. seems that there was an error in my inetd.conf file. after i edited it worked. – dnl Sep 22 '15 at 19:14