LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-23-2007, 05:12 PM   #1
nazs
Member
 
Registered: Apr 2005
Posts: 57

Rep: Reputation: 15
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

Last edited by nazs; 04-24-2007 at 12:10 AM.
 
Old 04-23-2007, 07:27 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
touch cur_dump.rodanth

echo "1455"* >> cur_dump.rodanth
Are you trying to execute these on the target machine?



Cheers,
Tink
 
Old 04-23-2007, 07:37 PM   #3
nazs
Member
 
Registered: Apr 2005
Posts: 57

Original Poster
Rep: Reputation: 15
Yes I am.
But once it slog's into the other machine it will not go any further.

Nazs
 
Old 04-23-2007, 08:25 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You could execute individual commands on the remote machine using:
Code:
ssh remotehost command
Make sure you escape wild-cards to stop your local shell expanding them. You can quote multiple commands and separate them with semi-colons. i.e. for your script:
Code:
ssh abcd@xfer.whatever.com 'touch cur_dump.rodanth ; echo "1455"* >> cur_dump.rodanth'
 
Old 04-24-2007, 09:51 AM   #5
nazs
Member
 
Registered: Apr 2005
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks Matthew. I will give this a try today.
 
Old 04-24-2007, 05:30 PM   #6
nazs
Member
 
Registered: Apr 2005
Posts: 57

Original Poster
Rep: Reputation: 15
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
 
Old 04-24-2007, 05:39 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Does the script work when you manually run it on the remote
machine while you're logged in?


Cheers,
Tink
 
Old 04-24-2007, 06:02 PM   #8
nazs
Member
 
Registered: Apr 2005
Posts: 57

Original Poster
Rep: Reputation: 15
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
 
Old 04-24-2007, 06:06 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 04-24-2007, 06:11 PM   #10
nazs
Member
 
Registered: Apr 2005
Posts: 57

Original Poster
Rep: Reputation: 15
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
 
Old 04-24-2007, 06:19 PM   #11
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
ssh, not slogin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SCP: No such file or directory...but its there!? Baix Linux - Newbie 20 07-28-2012 02:42 PM
write a sript to edit proxy settings NDR008 Programming 22 11-28-2006 07:48 AM
need shell backup sript maxut Linux - Software 2 10-12-2004 10:54 AM
execute sript? cloids Linux - Software 1 01-15-2004 01:03 PM
SCP ??? where did the file go ?????? lub0 Linux - Security 3 10-07-2003 05:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration