Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Technical Support _ A ssh node problem in the shell

Posted by: ytyyutianyun Nov 16 2011, 01:47 AM

I want to enter the command step by step automatically with a shell

when I run the shell,the program only jump to ssh node1,and do nothing else.
Help and thanks.
Here is the program:

#!/bin/bash
ssh node1
cd /us1
nohup matlab < pi11081.m >& name.out &
cd /us2
nohup matlab < pichuli2.m >& name.out &
ssh node2
cd /us1
nohup matlab < pichuli3.m >& name.out &
cd /us2
nohup matlab < pichuli4.m >& name.out &
ssh node3
cd /us1
nohup matlab < pichuli5.m >& name.out &
cd /us2
nohup matlab < pichuli6.m >& name.out &

Posted by: michaelk Nov 16 2011, 07:05 AM

Basically when you run ssh it starts another tty so the commands following ssh are never executed.
You can run commands from ssh like

ssh -n -f node1 "sh -c \"cd /us1; nohup matlab <pi11081.m> name.out &\""

Posted by: ytyyutianyun Nov 16 2011, 10:46 PM

QUOTE (michaelk @ Nov 16 2011, 07:05 AM) *
Basically when you run ssh it starts another tty so the commands following ssh are never executed.
You can run commands from ssh like

ssh -n -f node1 "sh -c \"cd /us1; nohup matlab <pi11081.m> name.out &\""



Thanks!
When I posted this, I continued searching some solutions and find "rsh" can do my thing. But I only can execute only one command and maybe I will learn it.
And someone else ask me to do like this:


ssh node1 << EOF
cd /us1
nohup matlab < pi11081.m >& name.out &
cd /us2
nohup matlab < pichuli2.m >& name.out &
exit
EOF



Last of all, thanks

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)