Getting data from an ftp address

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
SWW
Participant
Posts: 29
Joined: Thu Nov 11, 2004 12:51 pm
Location: Louisville

Getting data from an ftp address

Post by SWW »

I am using a control job that reads parameters form a parameter.ini file. The server job is to get a zip file, unzip to a folder, copy certain files to another folder, and write those records to a table. My trouble is getting the zip file from an ftp site. I have created a .bat file which the control job reads.

the copy.bat text is:

open 10.10.10.10
user
username
password
lcd D:\tote\holfolder\holzip
mget *18*.zip
y
y
y
quit

If I run this code at a dos prompt and type:
D:\ftp -n -s:copy.bat
it will go to the ftp site and put the zip file in the holzip folder.

In my control job at the CALL DSExecute I have
CALL DSExecute(sFTP_COPY_Parm,"ftp -n -s:copy.bat " , "Job Control")

Where the sFTP_COPY_Parm = D:\ and the copy.bat file is located on the d drive.

The error I receive is 'D:\ftp -n' is not a recognized command.

Any idea on the syntax needed to open an ftp and extract the file using DSExecute would be very helpful.

Thanks!!!
SWKYDERBY
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Re: Getting data from an ftp address

Post by ogmios »

Put your ftp command in a batch file and use the full path to this batch file to execute it via DSExecute.

Also use the full path to copy.bat

Ogmios
In theory there's no difference between theory and practice. In practice there is.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check the syntax for the DSExecute command. You need four parameters, only one of which is the command to execute.

First parameter is the O/S, in your case "DOS". Second is the command(s) to execute. Third is an array to hold any screen output from the command and lastly the parameter that holds the status of the command that was executed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SWW
Participant
Posts: 29
Joined: Thu Nov 11, 2004 12:51 pm
Location: Louisville

Post by SWW »

Thanks for the replies. Here is the piece of coding that I using to try and connect to an ftp site along with the .bat file. I made a couple of changes and the job get hung.

Any suggestions!!!


*Copy bay file to a local drive
Call DSLogInfo("Copying files by calling batch script via DSExecute command...", "Job Control")
Call DSLogInfo("Executing script to copy files from source data dir to copy to dir ", "Job Control")
Call DSExecute("NT",sFTP_COPY_Parm:"copy_Hol.bat ", msgs, rtncd)
Call DSLogInfo("Executing command - ":sFTP_COPY_Parm:"copy_Hol.bat ", "Job Control")
Call DSLogInfo("msgs is ":msgs, "Job Control")
Call DSLogInfo("rtncd is ":rtncd, "Job Control")


sFTP_COPY_Parm: is set D:\


Copy_Hol.bat file

ftp -n
open 10.10.10.10
user
username
password
lcd D:\Tote_Raw\Hollywood\Hol_zip
get *18*.zip
y
y
y
quit
SWKYDERBY
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,
On what platform is your DataStage server and client?


Are you doing ftp from Dos to Unix?

Ketfos
SWW
Participant
Posts: 29
Joined: Thu Nov 11, 2004 12:51 pm
Location: Louisville

Post by SWW »

Hi,
The platform for the server is windows 2000. The client is WindowsXP.
SWKYDERBY
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,
I feel the problem is in following command.

Call DSExecute("NT",sFTP_COPY_Parm:"copy_Hol.bat ", msgs, rtncd)


have you tried passing a different parameter for the second argument, namely sFTP_COPY_Parm:"copy_Hol.bat ".

Try to pass something like "dir > c:\testfile" in second argument to DSExecute.

Then see if you get the output of this command in a file.
This will help you in finding if you are passing the argument correctly.

Ketfos
wdudek
Participant
Posts: 66
Joined: Mon Dec 08, 2003 10:44 am

Post by wdudek »

I haven't used the DSExecute to do this, but we do something similiar with the command stage and ftp in our jobs, using almost the same syntax

Code: Select all

ftp -s:d:\ldrfiles\ftp_scripts\lind
Don't know if this helps in any way.
Post Reply