Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-10-2010
Registered User
 

Join Date: Sep 2008
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Sponsored Links
    #2  
Old 03-10-2010
karthigayan's Avatar
Registered User
 

Join Date: Apr 2009
Location: India , Chennai
Posts: 137
Thanks: 0
Thanked 3 Times in 3 Posts
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.
Sponsored Links
    #3  
Old 03-10-2010
pludi's Avatar
pludi pludi is offline Forum Staff  
Cat herder
 

Join Date: Dec 2008
Location: Vienna, Austria, Earth
Posts: 5,486
Thanks: 38
Thanked 324 Times in 301 Posts
"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
Registered User
 

Join Date: Feb 2007
Posts: 113
Thanks: 4
Thanked 3 Times in 3 Posts
Is it producting any error message.?
It seems your script looks okay...
Sponsored Links
    #5  
Old 03-10-2010
Registered User
 

Join Date: Sep 2008
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
The problem is it is not producing any error message.
Sponsored Links
    #6  
Old 03-10-2010
amitranjansahu's Avatar
Registered User
 

Join Date: Jan 2009
Location: Bangalore,INDIA
Posts: 503
Thanks: 4
Thanked 26 Times in 26 Posts
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.

Sponsored Links
    #7  
Old 03-10-2010
Registered User
 

Join Date: Feb 2007
Posts: 113
Thanks: 4
Thanked 3 Times in 3 Posts

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 06:34 AM.. Reason: code tags, please...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script not working ShinTec UNIX for Dummies Questions & Answers 3 01-22-2010 07:26 AM
Perl script 'system' linking to local shell script not working phpfreak Shell Programming and Scripting 5 10-16-2009 04:56 AM
Script not working with SCO wollop Shell Programming and Scripting 4 03-20-2009 12:20 PM
Script not working..."sort" not working properly.... Rahulpict Shell Programming and Scripting 23 03-16-2009 10:13 AM
Pls. Help my script not working as it should cocoabeauty1 Shell Programming and Scripting 1 07-28-2007 05:11 PM



All times are GMT -4. The time now is 12:54 AM.