scp is not working through sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp is not working through sh script
# 1  
Old 03-10-2010
scp is not working through sh script

Hi All,

I am generating a ~ delimited file from oracle table and then transfer it to another server through scp.

Code:
 
if [ -f $COM_DIR/ABC.txt ]
then
 scp $COM_DIR/ABC.txt unix.nam.nsroot.net:/home/magna/dum/ABC.txt 
else
 echo "File does not exist, please check" >>$LOG
fi

The script generates the file, but not able to deliver it to another server. To check what is the problem with scp command, i have tried to redirect the output to the LOG file like...

Code:
 
if [ -f $COM_DIR/ABC.txt ]
then
 scp $COM_DIR/ABC.txt unix.nam.nsroot.net:/home/magna/dum/ABC.txt >> $LOG
else
 echo "File does not exist, please check" >>$LOG
fi

but still it is not working.

While i executed only the scp command on command prompt, it works. Can someone tell me what could be a problem?
# 2  
Old 03-10-2010
I too tried with scp in script and it got work,check the returned error.
And one more thing you can not capture the error by using '>>'.It is used to redirect the stdout to a file not stderr.
# 3  
Old 03-10-2010
"It's not working" is about as useful as telling your doctor "it hurts".

What error messages do you get in your logfile (which you should redirect stderr to too, using '2>>$LOG')? Are you running the script as your user, or as a different id? By hand, or via an automated mechanism like cron?
# 4  
Old 03-10-2010
Is it producting any error message.?
It seems your script looks okay...
# 5  
Old 03-10-2010
The problem is it is not producing any error message.
# 6  
Old 03-10-2010
use -v option to debug

Code:
scp -v  $COM_DIR/ABC.txt unix.nam.nsroot.net:/home/magna/dum/ABC.txt >> $LOG


  -v                      Verbose mode. Causes scp and  ssh(1)
                             to  print  debugging  messages about
                             their progress. This is  helpful  in
                             debugging   connection,  authentica-
                             tion, and configuration problems.

# 7  
Old 03-10-2010
Code:
if [ -f $COM_DIR/ABC.txt ]
then
 scp $COM_DIR/ABC.txt unix.nam.nsroot.net:/home/magna/dum/ABC.txt 1> /usr2/spool/out1.txt 2> /usr2/spool/out2.txt
else
 echo "File does not exist, please check" >>$LOG
fi

Note: Change log path name.

Last edited by pludi; 03-10-2010 at 07:34 AM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

scp command not working

Hi All, I have automated the file transfer process using shell script.I used passwordless SCP to copy the files to my remote server as below. scp -P 2022 -v Test.dat username@Host:destination_folder But the files are not copied to the destination folder.The execution is terminated with... (1 Reply)
Discussion started by: Syruss
1 Replies

2. UNIX for Dummies Questions & Answers

scp command not working

I am trying to copy a file from a remote linux server to my local ubuntu box. I am issuing the following command: scp -v root@remote_server_IP:/test /data The output of the command is : OpenSSH_6.6, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config... (3 Replies)
Discussion started by: Palak Sharma
3 Replies

3. Shell Programming and Scripting

Scp/Rsync transfers stopped working?

Hi all, I have a backup script from my work computer to my home computer for my research for multiple reasons. It's a simple rsync script, with about 5 gigs of data. (Obviously with rsync it doesn't transfer 5 GB every time.). Recently, it has stopped working, scp also doesn't work, it simply... (1 Reply)
Discussion started by: corrado33
1 Replies

4. Shell Programming and Scripting

scp not working in expect script

Hi All, I run the scp command in shell prompt without issue, but when on expect script as below: #!/usr/bin/expect spawn scp /var/spool/sms/failed.tar.gz abc@10.10.12.2:/home/abc expect "abc@10.10.12.2's password: " send "abcfef\r" exit 0 It looks not working at all and the... (3 Replies)
Discussion started by: elingtey
3 Replies

5. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

6. Solaris

SCP not working while SSH works

Dear expert, I have gone through the thread A similar error arising for me , please find the debug logs. I have tried from another server to push a file using scp but not working for me. i am using SunOS SUNW,SPARC-Enterprise machine. Thanks (5 Replies)
Discussion started by: posix
5 Replies

7. UNIX for Dummies Questions & Answers

scp not working because of prompt (AIX, tcsh)

Hello, I have this problem: I have a server to which I ssh, and it has a special prompt request. The prompt is done by a ?prompt command. It is fine with SSH, since the prompt I guess gets some input, but when I use SCP, the copy always fails. So, I was wondering if there is maybe a... (1 Reply)
Discussion started by: lastZenMaster
1 Replies

8. Solaris

ssh and scp not working

Dear All, whenever i try the command ssh , it is giving the below error. ld.so.1: ssh: fatal: relocation error: file /usr/bin/ssh: symbol SUNWcry_installed: referenced symbol not found Killed For SCP also the same error is coming. Pl reply me if you have answers. Rj (4 Replies)
Discussion started by: jegaraman
4 Replies

9. AIX

scp not working while ssh works

I try to transfer a file from a Linux host to an AIX-host via scp, which fails. Logging into the AIX-system from the same Linux-system via ssh works well and i am a bit at a loss where to look. The original setup was with a user account provided via LDAP, but because of the error message (see... (4 Replies)
Discussion started by: bakunin
4 Replies

10. Programming

Controlling a child's stdin/stdout (not working with scp)

All, Ok...so I know I *should* be able to control a process's stdin and stdout from the parent by creating pipes and then dup'ing them in the child. And, this works with all "normal" programs that I've tried. Unfortunately, I want to intercept the stdin/out of the scp application and it seems... (9 Replies)
Discussion started by: DreamWarrior
9 Replies
Login or Register to Ask a Question