Reg: SCP issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reg: SCP issue
# 8  
Old 11-19-2007
how are you intending to use the sleep? Smilie
# 9  
Old 11-19-2007
honestly i dont know how sleep can help u in resolving timeouts...am curious to know about what you are doing too :-P

~Sage
# 10  
Old 11-19-2007
Hi Everybody,

Please find my script

Code:
#!/bin/ksh
dir_path=""/bp01/secftp/samsun/prfile/FTP/REFUND_RESTATEMENT_REPORTS/poirty/Production/Internal";

cp_cmd1="/usr/local/bin/ssh -v pickme@brad.wanted.com << EOF"
cp_cmd2="cp -R "$dir_path/mail rpt" $dir_path/Archive"
cp_cmd3="EOF"

echo open $Infahost
sleep 1
echo $Infaftplogin
sleep 1
echo $Infaftppasswd
sleep 1
echo $cp_cmd1
sleep 5
echo $cp_cmd2
sleep 5
echo $cp_cmd3
sleep 5

I am calling the script using telnet is ...sh -c 'test_cp | telnet' and logging as a different user
'tstsrc' since tstsrc has only got permission to ssh to the server.For all other
user names the script will ask for pickme password...

Doubt:

Code:
sleep 5 sommand will sleep my server or brad.wanted.com server

thanks,
sam
# 11  
Old 11-20-2007
What errors are you getting when you run the script?
Have you run it by hand, or put set -x at the top?

It appears that you are not using scp at all, but using telnet to connect to a server to ssh to remote into anoter box and then running multiple copy commands. The cp command will not return a prompt before it is done copying, so a sleep wouldn't do any good.
# 12  
Old 11-20-2007
but i am getting the prompt before the entire file is being copied..ie before the entire process is over...

thanks for the response
sam

Last edited by sam99; 11-20-2007 at 03:51 AM..
# 13  
Old 11-20-2007
Cmd you run:
sh -c 'test_cp | telnet'


Code:
#!/bin/ksh
dir_path=""/bp01/secftp/samsun/prfile/FTP/REFUND_RESTATEMENT_REPORTS/poirty/Production/Internal";

Code:
echo open $Infahost
sleep 1
echo $Infaftplogin
sleep 1
echo $Infaftppasswd
sleep 1
echo "/usr/local/bin/ssh -v pickme@brad.wanted.com << EOF"
sleep 5
echo "cp -R "$dir_path/mail rpt" $dir_path/Archive"
sleep 5
echo "EOF"
sleep 5

If you telnet to server1 and run this:
/usr/local/bin/ssh -v pickme@brad.wanted.com << EOF
cp -R "$dir_path/mail rpt" $dir_path/Archive
uname -a
EOF
uname -a


Does it print anything to the screen before the copy is done?
If everything is right, it should do a recursive copy, THEN print the remote servername and the local servername.
# 14  
Old 11-20-2007
i ran the code in the server and it is displaying the remore server name and the local machine name...the copying is happening fine also
Please find below...

Code:
OpenSSH_4.3p2, OpenSSL 0.9.7i 14 Oct 2005
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug1: Reading configuration data /usr/local/etc/ssh_config
debug1: Connecting to brad.wanted.com [11.206.8.117] port 22.
debug1: Connection established.
debug1: identity file /home/testsrc/.ssh/identity type -1
debug1: identity file /home/testsrc/.ssh/id_rsa type -1
debug1: identity file /home/testsrc/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.6.1p2
debug1: match: OpenSSH_3.6.1p2 pat OpenSSH_3.*
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: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'brad.wanted.com' is known and matches the RSA host key.
debug1: Found key in /home/testsrc/.ssh/known_hosts:5
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
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/testsrc/.ssh/identity
debug1: Trying private key: /home/testsrc/.ssh/id_rsa
debug1: Offering public key: /home/testsrc/.ssh/id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 434
debug1: read PEM private key done: type DSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Linux m9llalx016 2.4.21-20.ELsmp #1 SMP Wed Aug 18 20:46:40 EDT 2004 i686 i686 i386 GNU/Linux
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 5.2 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
AIX kiwlprty002 3 5 00C3EF5A4C00

when include the same in the shell script it is logging out without full copy...

thanks,
sam
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't solve a simple SSH/scp issue.. Please help.

Disclaimer: I tried searching but wasn't able to get to the answer so please don't flame. Scenario: I have a root script that generates a file on box1 and then needs to scp it over to box2 using user1. Both boxes are running open-ssh. root@locat-host# scp /tmp/file1 user1@box2:/tmp/file1 ... (10 Replies)
Discussion started by: denissi
10 Replies

2. Shell Programming and Scripting

Issue with scp to whole folder

previously 1 folder was created in a week. but now it creating more than 1 folder. shown as belowfor example:-------------------- 1 Aug A 2 Aug B 8 Aug M. Now i want scp to the whole content for whole folder. Let say in first week having 2 folder which need to scp to remaote in twice... (1 Reply)
Discussion started by: rabindratech
1 Replies

3. Shell Programming and Scripting

scp/untar .tar file in parallel issue

Hi Guys, I am facing a strange issue while doing parallel (using & for background) scp/untar operation from my unix box to multiple unix boxes... I am getting tar : unexpected EOF in archive error the code is as follows.,,, for i in 10 do sh -c "scp <command> ; ssh tar -xf <tar> -C... (4 Replies)
Discussion started by: mihirvora16
4 Replies

4. UNIX for Advanced & Expert Users

scp/untar in parallel issue tar : Unexpected EOF in archive

Hi Guys, I am facing a strange issue while doing parallel (using & for background) scp/untar operation from my unix box to multiple unix boxes... I am getting tar : unexpected EOF in archive error the code is as follows.,,, for i in 10 do sh -c "scp <command> ; ssh tar -xf <tar> -C... (1 Reply)
Discussion started by: mihirvora16
1 Replies

5. Solaris

scp issue

Hi I am trying to copy file from one server to another server. i used : scp filename username\@targerserver:path i got this is error : ssh: servername: node name or service name not known lost connection Please advice on this Thanks, Mani (1 Reply)
Discussion started by: Mani_apr08
1 Replies

6. UNIX for Dummies Questions & Answers

scp issue

I've got an ssh server on each pc in my LAN. I wanna use scp to copy files, but it doesn't work. 0;4:59pm% scp mghis@localhost:/home/mghis/foobar mghis@192.168.0.3:/home/mghis/foobar mghis@192.168.0.3's password: < I type in the remote password > mar 28 set 2010, 17.00.26, CEST 17:00:26 up... (4 Replies)
Discussion started by: mghis
4 Replies

7. UNIX for Dummies Questions & Answers

scp issue

hi, after scp from a mac to a unix server and back a set of .wav files (originally generated by ppt with 'record narration') become corrupted somehow, and when opened the sound files has become noise. non-.wav files in the same folder are not affected. strangely, the problem only seems to... (0 Replies)
Discussion started by: halcroves
0 Replies

8. UNIX for Dummies Questions & Answers

doubt reg SCP

Hi , I have a doubt reg SCP . For eg.. FileA is in host1 .Is it possible to receive fileA by logging to host2 using SCP.. Please let me know what is the major difference between scp and sftp.. We can use both for file transfer(correct me if am wrong) (4 Replies)
Discussion started by: rogerben
4 Replies

9. Shell Programming and Scripting

Reg : telnet password issue

Hi All, I am working on AIX 5.3. My requirement is to telnet to a server and scp a file from another server In my shell script i am using telnet to enter to a server and i am echoing the password as below echo open $Infahost sleep 1 echo $Infaftplogin sleep 1 echo $Infaftppasswd... (3 Replies)
Discussion started by: sam99
3 Replies

10. SCO

reg:rm -R is not working

I am installing the my package in SCO unix 5.0 .so it will create some temporary directories and files and same will delete.So , 'rm -R ' is not working in system .in the package only it has given this command,so now without this command working we can not go forward. so kindly help in this... (1 Reply)
Discussion started by: mokri_1980
1 Replies
Login or Register to Ask a Question