First thanks for the tips! I verified the permissions on the target directory are set appropriately. I started from scratch and have gotten it to work, however, I had to create two separate files to make this work. Ie.
sendfile.sh contains:
sftp -B up.txt
up.txt contains:
open psadmin@psbhvt2b
ascii
cd sshtest
put mj.txt
quit
Is there any way of getting this to run using only one script? Everytime I try to run the following it does not work:
/apps/ssh2/bin/sftp2 psadmin@psbhvt2b << marker
ascii
cd /home/psadmin
put mj
bye
marker
Here is the verbose output:
sshftp
SshFileCopy/sshfilecopy.c:673: Making local connection.
SshFileXferClient/sshfilexferc.c:1317: ext_name `newline@vandyke.com', data:
00000000: 0a .
SshFileCopy/sshfilecopy.c:616: Connection to local, ready to serve requests.
Sftp2/sftp2.c:412: Connection ready.
SshReadLine/sshreadline.c:2420: Initializing ReadLine...
SshFileCopy/sshfilecopy.c:687: Connecting to remote host. (host = psadmin@psbhvt2b, user = NULL, port = NULL)
Sftp2/sftp2.c:3364: Couldn't find ssh2 on path specified (/usr/local/bin/ssh2). Trying default PATH...
argv[0] = ssh2
argv[1] = -v
argv[2] = -x
argv[3] = -a
argv[4] = -opasswordprompt=%U@%H's password:
argv[5] = -oauthenticationnotify=yes
argv[6] = psadmin@psbhvt2b
argv[7] = -s
argv[8] = sftp
SshSigChld/sigchld.c:238: Registering handler for pid 59104.
SshSigChld/sigchld.c:238: Registering handler for pid 59104.
debug: SshConfig/sshconfig.c:3072: Metaconfig parsing stopped at line 3.
debug: SshConfig/sshconfig.c:3364: Read 3 params from config file.
debug: Ssh2/ssh2.c:1751: Found user config file '/home/psadmin/.ssh2/ssh2_config'
debug: SshConfig/sshconfig.c:3364: Read 1 params from config file.
debug: Connecting to psbhvt2b, port 22... (SOCKS not used)
debug: Ssh2Transport/trcommon.c:3748: My version: SSH-1.99-3.2.9 F-SECURE SSH 3.2.3
debug: client supports 2 auth methods: 'publickey,password'
debug: Ssh2Common/sshcommon.c:588: local ip = 161.128.143.12, local port = 34599
debug: Ssh2Common/sshcommon.c:590: remote ip = 161.128.143.13, remote port = 22
debug: SshConnection/sshconn.c:1945: Wrapping...
debug: Ssh2/ssh2.c:1002: Opening /dev/tty for queries.
debug: SshReadLine/sshreadline.c:2420: Initializing ReadLine...
debug: Remote version: SSH-2.0-3.2.9 F-SECURE SSH 3.2.3
debug: Major: 3 Minor: 2 Revision: 9
debug: Ssh2Transport/trcommon.c:1377: lang s to c: `', lang c to s: `'
debug: Ssh2Transport/trcommon.c:1443: c_to_s: cipher aes128-cbc, mac hmac-sha1, compression none
debug: Ssh2Transport/trcommon.c:1446: s_to_c: cipher aes128-cbc, mac hmac-sha1, compression none
debug: Remote host key found from database.
debug: Ssh2Common/sshcommon.c:380: Received SSH_CROSS_STARTUP packet from connection protocol.
debug: Ssh2Common/sshcommon.c:430: Received SSH_CROSS_ALGORITHMS packet from connection protocol.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
N O T I C E - P R O P R I E T A R Y S Y S T E M
This system is intended to be used solely by authorized
users in the course of legitimate corporate business.
Users are monitored to the extent necessary to properly
administer the system, to identify unauthorized users
or users operating beyond their proper authority, and
to investigate improper access or use. By accessing
this system, you are consenting to this monitoring.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
debug: server offers auth methods 'publickey,password'.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1794: Starting pubkey auth...
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1751: Agent is not running.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1549: Got 0 keys from the agent.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "/home/psadmin/.ssh2/id_dsa_2048_a" to candidates
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1529: Trying 1 key candidates.
debug: Constructing and sending signature in publickey authentication.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:836: reading private key /home/psadmin/.ssh2/id_dsa_2048_a
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1890: Public key authentication was successful.
debug: Ssh2Common/sshcommon.c:340: Received SSH_CROSS_AUTHENTICATED packet from connection protocol.
debug: SshReadLine/sshreadline.c:2478: Uninitializing ReadLine...
debug: Ssh2/ssh2.c:765: Returning user input stream to original values.
debug: Ssh2Common/sshcommon.c:915: num_channels now 1
Sftp2/sftp2.c:3295: buffer: 'AUTHENTICATED YES
'
debug: SshTtyFlags/sshttyflags.c:354: Not a tty. (fd = 0)
debug: Ssh2ChannelSession/sshchsession.c:3161: Requesting subsystem sftp
SshFileXferClient/sshfilexferc.c:1317: ext_name `newline@vandyke.com', data:
00000000: 0a .
SshFileCopy/sshfilecopy.c:616: Connection to remote host 'psadmin@psbhvt2b', ready to serve requests.
sftp>
ssh_pipe_stream_destroy
SshReadLine/sshreadline.c:2478: Uninitializing ReadLine...
debug: SshConnection/sshconn.c:406: EOF from channel stream
debug: Ssh2ChannelSession/sshchsession.c:2249: received exit status : 0
psadmin@psfsta ==> debug: Ssh2Common/sshcommon.c:881: num_channels now 0
debug: Got session close with exit_status=0
debug: Ssh2Common/sshcommon.c:713: Destroying SshCommon object.
debug: SshConnection/sshconn.c:1997: Destroying SshConn object.
The error I hightlighted in red above does not appear be causing the problem since I am using the same ssh/sftp command in the first set of scripts.
Any help would be greatly appreciated!!!
Everpro