Stuck on script to scp a file
Hi All,
I am doing what you guys probably think a pretty basic script. I am just not that good at it yet. And I am sure mine is 3 times longer than it should be but i am stuck. I have to scp a file to another server. And then some how slogin to that server and continue a few more lines in the script. I have exchanged keys and can slogin without needing a password. It will login to the other server but the script will not continue to run after that. Is there a command to make it continue? This is my script below. #!/bin/sh pos=/usr/pa/archive/warner/rodanthe/pos archive=/usr/pa/archive/warner/vrodanth/pos/archive dest=/usr/pa/archive/warner/vrodanth/pos/rodanth cd "$pos" gunzip 1455* for file in 1455* do cp "$file" "$dest/${file%%-*}" gzip 1455* mv "$pospay"/*.gz "$archive" cd "$dest" scp 1455* abcd@xfer.whatever.com:/home/wfs slogin abcd@xfer.whatever.com touch cur_dump.rodanth echo "1455"* >> cur_dump.rodanth done Also after the last line echo "1455"* >> cur_dump.rodanthi need to call another script that is on the server i slogged onto. How would i do that? Thanks, Nazs |
Code:
touch cur_dump.rodanth Cheers, Tink |
Yes I am.
But once it slog's into the other machine it will not go any further. Nazs |
You could execute individual commands on the remote machine using:
Code:
ssh remotehost command Code:
ssh abcd@xfer.whatever.com 'touch cur_dump.rodanth ; echo "1455"* >> cur_dump.rodanth' |
Thanks Matthew. I will give this a try today.
|
I modified the script and everything runs good till the very last command. The last command is to call another script to run on the remote machine it has logged onto. This is the error it gives me: bad interpreter: No such file or directory: /bin/sh
I will paste the update script below and mark in red the place the script stops. #!/bin/sh pos=/usr/pa/archive/warner/rodanthe/pos archive=/usr/pa/archive/warner/vrodanth/pos/archive dest=/usr/pa/archive/warner/vrodanth/pos/rodanth cd "$pos" #CHECK IF THERE ARE ANY POSITIVE PAY FILES if [ `find . -type f -maxdepth 1 -name "1455*" | wc -l` -eq 0 ]; then echo "Exit NO FILES" exit else gunzip 1455* for file in 1455* do cp "$file" "$dest/${file%%-*}" gzip 1455* mv "$pospay"/*.gz "$archive" cd "$dest" scp 1455* abcd@xfer.whatever.com:/home/wfs slogin abcd@xfer.whatever.com "touch cur_dump.rodanth;echo "1455"* >> cur_dump.rodanth;/home/abcd/remote-script" done fi Thanks, Nazs |
Does the script work when you manually run it on the remote
machine while you're logged in? Cheers, Tink |
Hi Tinkster,
I just tried to run that script manually on the remote machine. I received the same error: bad interpreter: No such file or directory Not sure what that exactly means. Nazs |
It could mean that there's no such file or directory, or that
you don't have permissions to run it. Check /bin to see whether the is a sh ls -l sh* Cheers, Tink |
ls -l sh*
-rwxr-xr-x 1 root root 616312 Dec 6 2004 sh The script is not being run by root. Is there a permision problem? Nazs |
ssh, not slogin
|
All times are GMT -5. The time now is 06:09 AM. |