I am generating a ~ delimited file from oracle table and then transfer it to another server through scp.
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...
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?
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.
"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?
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.
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