Results 1 to 3 of 3
Hi!
I am quite a Linux newbie and i'm trying to run a script on a remote host from within a script on my local machine:
Local Script:
#!/bin/kcsh
...
...
- 11-02-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 2
Remote script running another remote script
Hi!
I am quite a Linux newbie and i'm trying to run a script on a remote host from within a script on my local machine:
Local Script:
#!/bin/kcsh
...
ssh remote '/<Path to Script/script.sh "Arguments with blank"'.
....
Remote Script:
#!/bin/bash
. secondremotescript.sh
...
$variableformsecondremotescript
...
Normally the remote scripts runs another remote script which sets some variables. Unfortunately the first remote script stops when it comes to run the 2nd script with the error message: "No such file or directory". Executing the remote script when normally logged in via ssh (not via ssh in script) is no problem but running the ssh command from the script on command line doesn't work either.
I tried to execute "ls -l" on remote host an everything works fine: I get output on local machine.
I suppose i ran into some shell-subhell-varibale Problem? Or is the remote process killed because ssh in scripts closes connection immediately after dropping the command ? If this is the case i don't understand why i get error message: "Line10: No such file or directory". So the script seems to make it at least to line 10.
Many Thanks for ur help,
- 11-03-2009 #2Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
I think it has something to do with how you handle filename/directory name with spaces in either script.sh or secondremotescript.sh, ls -l displays all files and directories does not mean anything as it names with spaces correctly. Let me give you a quick example:
Under /tmp let's create two simple text file
Then we use a simple for loop to display the content of the .ttt files, without considering the special filename case (a b.txt), we would write the loop as [ I know a better way to accomplish this task is by using cat *.ttt, but I use for loop here for the sake of illustration ]:Code:cd /tmp echo "a" > a.ttt echo "a b" > "a b.ttt"
When you run this command you get the following errors right away:Code:for f in *.ttt; do cat $f; done
The solution is to put double quotation marks around $f:cat: a: No such file or directory
cat: b.ttt: No such file or directory
So I would suggest that you go through your scripts to find lines that require special attention on spaced file/directory names.Code:for f in *.ttt; do cat "$f"; done
- 11-04-2009 #3Just Joined!
- Join Date
- Nov 2009
- Posts
- 2
Solution
Thanks for your answer but i found a solution by changing my script like this:
ssh -t -t remote<<ABC
...
...
...
ABC
Just one -t did not work. Two -ts = "force tty allocation". I got no idea what this means in detail.
All i know is that when using only one -t i got the error message: TERM: undefined variable.
Running a remote script seems to make "tty allocation" necessary.:


Reply With Quote