Help - Search - Members - Calendar
Full Version: A ssh node problem in the shell
Linuxhelp > Support > Technical Support
ytyyutianyun
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 &
michaelk
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 &\""
ytyyutianyun
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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.