Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hello,
I am having trouble creating a batch script
to FTP a file from UNIX to NT. It seems that when I invoke the script, the ftp command invokes the interactive ftp interpreter and does not return control to my script.
And there is no way that i have found to pass
parameters to the ftp process to put the files...
On Windows NT there is the -s parameter which specifies a file to use to obtain the ftp commands;however, that option seems to be missing on the UNIX side.does anyone have any suggestions and possibly a sample korn shell script to ftp
a file without invoking interactive mode?I would think that this would be a common
process so that ftp can be automated via scheduled scripts.thank you to any and all that may be able to help me; I am new to UNIX and can use all the help I can get! thanks very much (:

I cheated by scheduling a WS_FTP task
on my PC to "pull" from UNIX, rather
than using a UNIX shell script to "push"
to my PC.Here is the DOS batch file which I scheduled:
c:\ws_ftp\ftp95pro -p f10a -ascii plessf10.plano.esc.eds.com:/export/home/hzwbh7/stats/xmin.txt local:\dcjunix\auto.ftp\djprfst.csv
cd c:\dcjunix\auto.ftp
copy /A prev.csv+djprfst.csv next /A
erase /f /q prev.csv
ren next prev.csv
erase /f /q xferlog.txt

This is dependent on the ftp client on your unix platform but the following should work on most:
#!/bin/sh
ftp -n -i remotehost <user username password
get filename
close
quit
!!

hi ,
here i have given the simple script to noninteractive script for ftp.
try this out..#! /bin/ksh
TMP_CMDS=/tmp/niru/fcmd
TMP_OUTPUT=/tmp/niru/fout
echo "open machine ip" > $TMP_CMDS
echo "user username passwd" >> $TMP_CMDS
echo "cd niru" >> $TMP_CMDS #where the file resides
echo "lcd /tmp/niru" >> $TMP_CMDS # where u want the files to get ftped
echo "binary" >> $TMP_CMDS # mode ur selection
echo "get filename " >> $TMP_CMDS #u can use mget for multiple filesecho "quit" >> $TMP_CMDS
ftp -vin > $TMP_OUTPUT
if [ $? -eq 0 ]
then
rm -f $TMP_OUTPUT
rm -f $TMP_CMDS
fi
Thanks,
niru..

Hi,
Additional question to this..
Is it possible to pass a shell variable to the ftp script..I am trying to get the filename dynamically associated with the ftp script. The filename could be passed as a shell variable..
Thanks
Sam

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |