Operating System - Microsoft
1752467 Members
5906 Online
108788 Solutions
New Discussion юеВ

Re: Need script to ftp single file

 
Vishal_1980
Regular Advisor

Need script to ftp single file

Hello Expert ,

 

I have to run the ftp comand from my local desktop to  ftp 1 single file.

 

This file is critical to copy for the application patch installation & upgrade.

 

Below are the steps that i am following.Can i make this commands in a script.

 

Open cmd window on MSCM Server
D:
cd MSCM/DSSO
 
(or DSSO)

ftp -nv srvname

user <userid>

bin

prompt

cd /law/c0xxyy/gen/perms_files
 

pwd

dir

get DSSO.jar

quit

 

Thanks & with regards,

Vishal

 

 

 

P.S. This thread has been moved from HP-UX > Languages and Scripting to Microsoft > general. - Hp Forum Moderator

8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: Need script to ftp single file

A quick Google search yielded some good results: http://lmgtfy.com/?q=windows+ftp+batch+file

 

Basically it will require 2 files.

 

The contents of the first file, names ftp-file.script, should be:

 

open srvname

userid

password

lcd /D "D:\MSCM\DSSO"

bin
prompt
cd /law/c0xxyy/gen/perms_files
pwd
dir
get DSSO.jar

bye

 

 

The second file, named ftp-file.bat, should be:

 

ftp -i -s:ftp-file.script

 

Then, when you want to FTP the file, just run the ftp-file.bat file.

Vishal_1980
Regular Advisor

Re: Need script to ftp single file

Hi Patrick ,

I did the same as you said .Created 2 files 1 with name ftp-file.script on to which i copied the content & run the command ftp -inv -s:ftp-file.script from the command prompt and got the below error ;

C:\Users\VPatankar>ftp -inv -s:ftp-file.script
Error opening script file ftp-file.script.

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.


Please suggest ...

Thanks Vishal
Patrick Wallek
Honored Contributor

Re: Need script to ftp single file

Are both files in the same directory?

 

The error indicates that it can't find the ftp-file.script file.

Vishal_1980
Regular Advisor

Re: Need script to ftp single file

Yes both the files are in the same folder....
Vishal_1980
Regular Advisor

Re: Need script to ftp single file

Hi Patrick,

When i run the batch file i got the below error...

C:\Users\VPatankar\Desktop>ftp -i -s:ftp-fil
ftp> open srv0536
Connected to srv0536.netaspx.com.
220 srv0536 FTP server (Version 4.2 Mon Dec
User (srv0536.netaspx.com:(none)):
500 'USER ': command not understood.
Login failed.
ftp> userid "kvaze"
Invalid command.
ftp>
ftp> password "passw0rd"
Invalid command.
ftp>
ftp> lcd /D "D:\MSCM\DSSO"
lcd local directory.
ftp>
ftp> bin
200 Type set to I.
ftp> prompt
Interactive mode On .
ftp> cd /law/c123da/gen/perms_files
530 Please login with USER and PASS.
ftp> pwd
530 Please login with USER and PASS.
ftp> dir
530 Please login with USER and PASS.
530 Please login with USER and PASS.
Patrick Wallek
Honored Contributor

Re: Need script to ftp single file

In my example the lines with userid and password are the actual userid and password.  You do NOT specify "user userid" or "password passw0rd" you just specify kvaze and passw0rd on each line.

Vishal_1980
Regular Advisor

Re: Need script to ftp single file

After changing the parameters as per you said , below is the output of the .bat file..
C:\Users\VPatankar\Desktop>ftp -i -s:ftp-fil
ftp> open srv0536
Connected to srv0536.netaspx.com.
220 srv0536 FTP server (Version 4.2 Mon Dec
User (srv0536.netaspx.com:(none)):
500 'USER ': command not understood.
Login failed.
ftp> kvaze
Invalid command.
ftp>
ftp> passw0rd
Invalid command.
ftp>
ftp> lcd /D "D:\MSCM\DSSO"
lcd local directory.
ftp>
ftp> bin
200 Type set to I.
ftp> prompt
Interactive mode On .
ftp> cd /law/c123da/gen/perms_files
530 Please login with USER and PASS.
ftp> pwd
530 Please login with USER and PASS.
ftp> dir
530 Please login with USER and PASS.
530 Please login with USER and PASS.
Please suggest...
Vishal_1980
Regular Advisor

Re: Need script to ftp single file

Also after login to UNIX i need to select the environment ,
below is the screen shot for the same...
Choose Environment
------------------
0. c0gart
1. c0tyfs
2. c0artd
3. c11eda
4. c10cfda

s. aspx Shell
l. View Customer names
x. Logout

Choice? :


here i have to give the option