SCP During Transfer to SunOS

Hi,

I'd like to seek your help in finding the cause of this problem. I utilize SCP command to transfer files from one server to another. I utilize the return code that SCP return so as to verify if transfer is ok or not. Below is a sample code that I created.

if scp /some/folder/sample.txt <userName>@<ipAddress>:/some/remote/path/
then
  echo "Successful"
else
  echo "Failed"
fi

This code is ok with Linux, AIX and HP-UX and it always return "Successful". But I just observed that it does not hold true when I transfer the file to SunOS (SunOS 5.9). It always return "Failed" transaction. But the file was transferred successfully to the SunOS remote server.

BTW, my staging server is running on Linux. Thanks in advance.

Please use CODE tags when posting logic.

Please post entire output of the error without the if logic.

scp /some/folder/sample.txt <userName>@sunbox:/some/remote/path/
echo $?

what SSH implementation are you using?

SSH Version: OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

scp /some/folder/sample.txt <userName>@sunbox:/some/remote/path/
echo $?

Return code is 0

Any idea? Thanks

Posted from my Samsung Galaxy S mobile.

Hi Neo,

I already provided the information that frank_rizzo asked.

Can someone crack the problem that I raised? Thanks.

actually - you did not provide everything I asked for.

add -vvv and post the ENTIRE output.

Here's the result:

$ scp -v sample.txt someuser@10.225.2.10:.
Executing: program /usr/bin/ssh host 10.225.2.10, user someuser, command scp -v -t .
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.225.2.10 [10.225.2.10] port 22.
debug1: Connection established.
debug1: identity file /home/someuser/.ssh/identity type -1
debug1: identity file /home/someuser/.ssh/id_rsa type 1
debug1: identity file /home/someuser/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.0.1
debug1: match: Sun_SSH_1.0.1 pat Sun_SSH_1.0*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host '10.225.2.10' is known and matches the RSA host key.
debug1: Found key in /home/someuser/.ssh/known_hosts:256
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received

|-----------------------------------------------------------------|
| This system is for the use of authorized users only. |
| Individuals using this computer system without authority, or in |
| excess of their authority, are subject to having all of their |
| activities on this system monitored and recorded by system |
| personnel. |
| |
| In the course of monitoring individuals improperly using this |
| system, or in the course of system maintenance, the activities |
| of authorized users may also be monitored. |
| |
| Anyone using this system expressly consents to such monitoring |
| and is advised that if such monitoring reveals possible |
| evidence of criminal activity, system personnel may provide the |

evidence of such monitoring to law enforcement officials.

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/someuser/.ssh/identity
debug1: Offering public key: /home/someuser/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -t .
Sending file modes: C0664 8 sample.txt
sample.txt 100% 8 0.0KB/s 00:00
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status -1

You forgot the "echo $?" this time. We need them both, from the same run, otherwise we can't tell how and/or if they're related.

Returned Value after execution of the code is 1. Pls. see last line in bold font...

scp -v sample.txt isodadm@10.225.2.10:.
echo $?

Executing: program /usr/bin/ssh host 10.225.2.10, user someuser, command scp -v -t .
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
....
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status -1
1