Results 1 to 5 of 5
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.
...
- 11-16-2011 #1Just Joined!
- Join Date
- Nov 2011
- Posts
- 3
Help!A ssh node problem in the shell
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 &
- 11-17-2011 #2Just Joined!
- Join Date
- Oct 2011
- Posts
- 15
I am sure it is not possible directly putting those commands in the script.
You need to use a loop and a conditional like
for host in node1 node2
do
and a conditional inside the loop.
if [ "$host" == "node1" ]; then
command for node1
fi
or use switch case.
experts will give you better advices, but by the time you can work on this.
- 11-17-2011 #3
Is it executing all the commands for node1? Or is it hanging at the login? You may want to put the commands inside of ssh, otherwise your script will not execute them remotely.
e.g. for node1
Code:ssh node1 cd /us1;nohup matlab < pi11081.m >& name.out &;cd /us2;nohup matlab < pichuli2.m >& name.out &
linux user # 503963
- 11-18-2011 #4Just Joined!
- Join Date
- Nov 2011
- Posts
- 3
- 11-18-2011 #5
The quotes are to escape any special characters, and therefore keeping your script from breaking.
linux user # 503963


Reply With Quote
