LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SCP succeeds but no file on other end? (https://www.linuxquestions.org/questions/linux-newbie-8/scp-succeeds-but-no-file-on-other-end-4175491952/)

ilesterg 01-20-2014 07:00 PM

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.

lleb 01-20-2014 07:41 PM

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?

ilesterg 01-20-2014 07:58 PM

Hi lleb,

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

Quote:

Originally Posted by lleb (Post 5101870)
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.

SAbhi 01-20-2014 09:52 PM

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.

ilesterg 01-20-2014 11:09 PM

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.

ilesterg 01-20-2014 11:14 PM

Quote:

Originally Posted by SAbhi (Post 5101926)
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.

SAbhi 01-20-2014 11:24 PM

Quote:

Originally Posted by ilesterg (Post 5101957)
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


All times are GMT -5. The time now is 11:44 PM.