I wrote a shell script to copy a file from Windows directory to a remote Linux machine. I'm using cygwin to run the script. The script gets executed without any error. I'm using pscp
to copy files, but the file is not being copied. Putty is installed & environment variable is set.
Without putting in .sh
file, the pscp
command copies the files.
#!/bin/bash
logFile=/cygdrive/e/Automated/Po_transfer/po_filesfileTransfer.log
d=`date +%d-%m-%Y`
t=$(date +"%T")
cd /cygdrive/e/Automated/Po_transfer/
FileName=`ls -tr|grep PO*_BV.csv >> $logFile`
pscp -pw abcd $FileName user@xxx.yy.zz.qq:/home/ckp/po
if [ $? = 0 ];
then
echo "$d $t $FileName transferred to Asics Factory successfully" >> $logFile
fi
The script has to copy the files to destination directory on Linux machine, but console shows:
./PO_Transfer.sh
PuTTY Secure Copy client
Release 0.70
Usage: pscp [options] [user@]host:source target
pscp [options] source [source...] [user@]host:target
pscp [options] -ls [user@]host:filespec