I need to write a shell script to transfer files from Unix server to windows machine. This script will be scheduled on scheduler to run at specified intervals
#!/bin/ksh
ftp -n alaska <<End-Of-Session
user sss01 sample
cd /home/sss01
lcd D:/sample
mget *.txt
bye
when I executed the above shell script. It throws error saying file location D:/sample not found.
Can somebody please help me in writing the script?
Thanks for you reply!
I added the EOF statement at the end. Now the session the coming out of ftp. but the error 'D:/Nagaraj: No such file or directory' still exists
can you please help..
It's complaining about the "lcd" command, telling the local system (that's running the FTP script) to change directory (as opposed to changing the directory on the FTP server.)
That looks like a Windows path to me (D:\sample). But your script is calling /bin/ksh. Are you on a Windows box, a Unix box, or a Windows box with SFU or Cygwin installed?
I created also script to transfer file from UNIX to WIn.but I had to set up ftp directory in windows(IIS) so I can just put my files in that directory..
I would also love to see is it possible to use lcd command so I could change windows directory in my unix script???
Shouldn't the slash be of the other type. The palce where u are specifying lcd would be D:\sample. and since the script is on Unix
cd D:\sample
and
lcd /home/sss01
ftplog=loglog.log
echo "$(date "+%H:%M:%S") - Attempt to FTP $1 to $2" > $ftplog
# do the FTP put
ftp -i -n <<EOF >> $ftplog
open <hereIPaddress>
user someuser somepass
put $localFile $remoteFile
ls $remoteFile
quit
EOF
./ftpscript localfile.txt
so by entering IP of my windows machine and execution of this script file goes to windows...and this works..but file goes to my directory I specified in IIS I was wondering can I tell in UNIX script where to place file when it is transfer from U. to W.??
results:
Connected to machine.
220 machine FTP server (Version 1.1.214.7 Thu Aug 10 09:57:38 GMT 2000) ready.
---> USER xxxxx
331 Password required for xxxx.
---> PASS XXXXXX
230 User xxxx logged in.
---> SYST
215 UNIX Type: L8
Remote system type is UNIX.
---> TYPE I
200 Type set to I.
Using binary mode to transfer files.
---> CWD /tmp/
250 CWD command successful.
Local directory now /xxxx/temp/
---> PORT xxx.xxx.xxx.xxx,188
200 PORT command successful.
---> TYPE A
200 Type set to A.
---> LIST *
150 Opening ASCII mode data connection for /usr/bin/ls.
-rwxrwxr-x 1 xxxxx xxxxx_sys 1003779 Jun 15 09:48 filename.txt
226 Transfer complete.
I wanted to register to this forum to introduce myself. My name is Joe Clark. I am a recruiter with TEKsystems in Illinois. We are a nationwide IT solutions company.
I am always looking for solid IT professionals who work in a Unix environment. Currently, I am working on a Unix to Windows migration position. I am having a difficult time finding qualified candidates. If anyone is interested, or knows of anyone who may be interested in this position, please let me know via email or telephone. My number is 847-632-9229. My email is eaclark@teksystems.com
If anyone is looking for new opportunities in the IT field, please let me know.