FTPing Multiple Files with Parameters
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
FTPing Multiple Files with Parameters
Hi All
i am trying to FTP a certain set of files from a file server to my Datastage Server using BASIC Script...
I have a small text file(FTPFile) with the FTP commands which looks as below
----------------
open FTPServerName
username
password
cd FAC
get count.txt
quit
-----------------------------------
My DataStage Basic Commands for calling this file looks like
------------------------------------------------------------------------
cmd = 'ftp -s:c:\FTPFile'
Call DSExecute("NT", cmd , Output, ExitStatus)
If ReturnCode = 1 Then
Call DSLogFatal("CountScript Failed", "JobControl")
End
-----------------------------------------------------------------------
Now i want to pass FTPservername,username and password as parameters
my cmd statement is not allowing any parameters.
Can you please suggest me how i can do this parameters instead of hard coding my values
Thanks
Pavan
i am trying to FTP a certain set of files from a file server to my Datastage Server using BASIC Script...
I have a small text file(FTPFile) with the FTP commands which looks as below
----------------
open FTPServerName
username
password
cd FAC
get count.txt
quit
-----------------------------------
My DataStage Basic Commands for calling this file looks like
------------------------------------------------------------------------
cmd = 'ftp -s:c:\FTPFile'
Call DSExecute("NT", cmd , Output, ExitStatus)
If ReturnCode = 1 Then
Call DSLogFatal("CountScript Failed", "JobControl")
End
-----------------------------------------------------------------------
Now i want to pass FTPservername,username and password as parameters
my cmd statement is not allowing any parameters.
Can you please suggest me how i can do this parameters instead of hard coding my values
Thanks
Pavan
You need to pass it as parameters to your FTPFile. Like
Your bat file should accept these. Once you can get your FTPFile running from command line. Then you can edit your Cmd as
where myServerName userMe passwdMe will be defined as arguments to your routine.
Code: Select all
FTPFile myServerName userMe passwdMe.
Code: Select all
cmd = 'ftp -s:c:\FTPFile ':myServerName userMe passwdMe
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
i changes the DOS batch file to
[open %1
%2
%3
cd FAC
get count.txt
quit]
and tried executing it from command line as follows...
C:\>dosscript1 servername username password
C:\>open servername
'open' is not recognized as an internal or external command,
operable program or batch file.
C:\>username
'username' is not recognized as an internal or external command,
operable program or batch file.
C:\>password
'password' is not recognized as an internal or external command,
operable program or batch file.]
It is not even recognising and going in to the FTP session to execute any commands....
I changed the batch file as
[ftp
open %1
%2
%3
cd FAC
get count.txt
quit]
With this the script is waiting for my input at the command prompt as
[C:\>dosscript1 servername username password
C:\>ftp
ftp>]
ca you please help me in figure out what i am missing in my DOS batch file
Thanks
Pavan[/code][/b]
[open %1
%2
%3
cd FAC
get count.txt
quit]
and tried executing it from command line as follows...
C:\>dosscript1 servername username password
C:\>open servername
'open' is not recognized as an internal or external command,
operable program or batch file.
C:\>username
'username' is not recognized as an internal or external command,
operable program or batch file.
C:\>password
'password' is not recognized as an internal or external command,
operable program or batch file.]
It is not even recognising and going in to the FTP session to execute any commands....
I changed the batch file as
[ftp
open %1
%2
%3
cd FAC
get count.txt
quit]
With this the script is waiting for my input at the command prompt as
[C:\>dosscript1 servername username password
C:\>ftp
ftp>]
ca you please help me in figure out what i am missing in my DOS batch file
Thanks
Pavan[/code][/b]
Try this
Code: Select all
ftp << EOF
open %1
%2
%3
cd FAC
get count.txt
quit
EOF
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
Nope it doesn't work...
Thanks
Pavan
Code: Select all
C:\>dosscript1 servername username password
<< was unexpected at this time.
C:\>ftp << EOF
C:\>
Pavan
Thats unix style. Was hoping it would work on NT. Anyways, check out thiswebsite. It tells you how to build a NT ftp script.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
Hi all
The Trick in solving this problem is in making the FTP DOS Script File at run time.
i have written the following DOS script
Hope this helps people in future reference
Thanks
Pavan
The Trick in solving this problem is in making the FTP DOS Script File at run time.
i have written the following DOS script
Code: Select all
set FTPADDRESS=green.rosettamarketing.com
set SITEBACKUPFILE=*.txt
set FTPUSERNAME=%1%
set FTPPASSWORD=%2%
CLS
> script.ftp USER
>>script.ftp ECHO %FTPUSERNAME%
>>script.ftp ECHO %FTPPASSWORD%
>>script.ftp ECHO binary
>>script.ftp ECHO cd FAC
>>script.ftp ECHO prompt
:: Use put instead of get to upload the file
>>script.ftp ECHO mget %SITEBACKUPFILE%
>>script.ftp ECHO bye
FTP -v -s:script.ftp %FTPADDRESS%
Thanks
Pavan
-
- Premium Member
- Posts: 142
- Joined: Mon Jun 27, 2005 5:31 pm
- Location: Atlanta GA
My DataStage Basic Commands for calling this file looks like
------------------------------------------------------------------------
cmd = 'ftp -s:c:\FTPFile'
Call DSExecute("NT", cmd , Output, ExitStatus)
If ReturnCode = 1 Then
Call DSLogFatal("CountScript Failed", "JobControl")
End
-----------------------------------------------------------------------
I cant stop wondering how this routine is working. You said if ReturnCode=1 then you are aborting the job and exiting the routine.
But there is no ReturnCode in your routine. It only has ExitStatus. The way the routine is running right now, it will never abort. You should say ExitStatus=1 instead of ReturnCode=1.
------------------------------------------------------------------------
cmd = 'ftp -s:c:\FTPFile'
Call DSExecute("NT", cmd , Output, ExitStatus)
If ReturnCode = 1 Then
Call DSLogFatal("CountScript Failed", "JobControl")
End
-----------------------------------------------------------------------
I cant stop wondering how this routine is working. You said if ReturnCode=1 then you are aborting the job and exiting the routine.
But there is no ReturnCode in your routine. It only has ExitStatus. The way the routine is running right now, it will never abort. You should say ExitStatus=1 instead of ReturnCode=1.
Venkat Velagapudi
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
From "Code Obfuscation 101":
Code: Select all
Equate ReturnCode LITERALLY "ExitStatus"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India