LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2014, 08:00 PM   #1
ilesterg
Member
 
Registered: Jul 2012
Distribution: Arch, CentOS, OpenSUSE Tumbleweed KDE
Posts: 526

Rep: Reputation: 56
SCP succeeds but no file on other end?


Hey guys,

I have this Unix script scheduled to transfer a certain file to a remote server using SCP.

Code:
scp -oIdentityFile=id_file file_to_transfer.csv remote_user@remoteserver.com:/remotedirectory
I trust that the script will be able to tell me through its logs whether it fails or not because if just checks the return code, like this:

Code:
scp command here
if [ Error -eq 0 ]
then
	echo "file transfer successful!" >> $logfile
else
	echo "file transfer failed!" >> $logfile
	exit 2
fi
For the past couple of days the receiver complains that they did not receive the files.

The question is, given that the return code of the scp command is checked, is there any way it would fail and my script will not be able to see it?

Cheers.
 
Old 01-20-2014, 08:41 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
depends on the errors message the system is checking. if the error command is not run exactly after the scp command then it could be returning a false positive. that is possible. have you manually run the scp command to verify that the file can be transmitted successfully?

working on the assumption that the script is correct, how do you know the receiver is just not foolish and does not know what they are looking at, or that there is not an error on their end?
 
Old 01-20-2014, 08:58 PM   #3
ilesterg
Member
 
Registered: Jul 2012
Distribution: Arch, CentOS, OpenSUSE Tumbleweed KDE
Posts: 526

Original Poster
Rep: Reputation: 56
Hi lleb,

Thanks for the feedback. The error command comes right after the scp command (please see code above).

Quote:
Originally Posted by lleb View Post
working on the assumption that the script is correct, how do you know the receiver is just not foolish and does not know what they are looking at, or that there is not an error on their end?
yes, this is exactly what I'm thinking and it's something I'd like to explain to my client.
 
Old 01-20-2014, 10:52 PM   #4
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
all i see is something like Error is used to see if the file sent successfully.
can try scp with "-v" and see whats happening .
untill you try sending the file manually and see the logs if the identity file was able to do a successful authentication because i cant see Identityfile as an option with "-O" identity file is given with "-i ID_file" (Though I am not pretty sure about this being the issue) but having a look at man scp may give you an idea.

Last edited by SAbhi; 01-20-2014 at 10:53 PM.
 
Old 01-21-2014, 12:09 AM   #5
ilesterg
Member
 
Registered: Jul 2012
Distribution: Arch, CentOS, OpenSUSE Tumbleweed KDE
Posts: 526

Original Poster
Rep: Reputation: 56
Wait, I just noticed that there is actually a CR after the scp command, like this:

Code:
scp command here

if [ Error -eq 0 ]
does it matter?

Cheers.
 
Old 01-21-2014, 12:14 AM   #6
ilesterg
Member
 
Registered: Jul 2012
Distribution: Arch, CentOS, OpenSUSE Tumbleweed KDE
Posts: 526

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by SAbhi View Post
all i see is something like Error is used to see if the file sent successfully.
can try scp with "-v" and see whats happening .
untill you try sending the file manually and see the logs if the identity file was able to do a successful authentication because i cant see Identityfile as an option with "-O" identity file is given with "-i ID_file" (Though I am not pretty sure about this being the issue) but having a look at man scp may give you an idea.
But, a successful transfer should imply a successful authentication, right? Which is why I think only the return code for a successful transfer is checked.

Cheers.
 
Old 01-21-2014, 12:24 AM   #7
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
Originally Posted by ilesterg View Post
But, a successful transfer should imply a successful authentication, right? Which is why I think only the return code for a successful transfer is checked.

Cheers.
A successfull transfer should have the file at the right place!! if its getting succeeded try giving a trailing slash "/" after the "/remote/dir/" *** the bold one and try again
 
  


Reply

Tags
scp, unix


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] end to end delay calculation in satellite links awk file problem-ns2.35 rianariana Linux - Software 3 11-23-2013 10:46 AM
[SOLVED] Add lines end of file above the end comments bkone Programming 2 02-27-2012 10:58 AM
Running a Crafted bash script yelds 'Unexpected end of file' at the end of the file MCLover1337 Linux - General 5 10-15-2011 09:29 AM
scp hangs at the end of a successful transfer dscholl Red Hat 1 07-17-2009 07:27 PM
scp progress on the recieving end? geomysterio Linux - Newbie 1 05-26-2009 03:48 PM


All times are GMT -5. The time now is 11:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration