Page 1 of 1

Calling FTP script within DataStage

Posted: Mon Mar 13, 2006 11:15 am
by kvercruy
Hi,

We have a problem using FTP in DataStage. We created a script that uses the .netrc file to connect automatically to a remote FTP server.

The macro definition creates a new directory on the FTP server and looks like:
macrodef ftpmkdir
mkdir newdir
bye

However, when executing a script in DataStage containing the following text:
echo "\$ ftpmkdir" | ftp servername

we receive the following output:
Name (main-labotest.vmm.be:dsadm): User dsadm cannot log in.
Login failed.

When executing this script in command line on the local server the script runs successfully.

Does anyone have some experience using FTP in DataStage (not using the FTP Stage)?

Kind regards,

Kristine

Posted: Mon Mar 13, 2006 11:42 am
by kduke
.netrc and macros can be disabled on the target server. If any shell script works at the command line and not within DataStage DSExecute or ExecSH is either a permissions problem or a environment variable issue. All DataStage jobs run as phantoms and do not execute the .profile so your UNIX environment is different. The .netrc is only for a specific user. If you want then post your whole shell script and please change the passwords and server names or ip addresses. Please use code tags before and after.

Posted: Mon Mar 13, 2006 4:42 pm
by roy
Hi,
Usually I prefer to build a FTP script on the fly and remove it after I'm done.
IHTH,

Script content

Posted: Tue Mar 14, 2006 12:41 am
by wvandegaer
kduke wrote:paste code
.netrc file

Code: Select all

machine [i]servername[/i]        
        login [i]login[/i]
        password [i]password[/i]

macdef ftpmkdir
        mkdir $1
        bye

macdef ftpremovedir
        rmdir $1
        bye
scriptfile mkdir.sh

Code: Select all

ftp [i]servername[/i]
$ ftpmkdir $1
DSExecute

Code: Select all

. /path/mkdir.sh [i]newdirectory[/i]

Posted: Tue Mar 14, 2006 6:55 am
by kduke
scriptfile mkdir.sh
ftp servername
$ ftpmkdir $1
Does not look right. What is the $ on line 2. In your first post you said this was the command:

Code: Select all

echo "\$ ftpmkdir" | ftp servername
If you can pipe into ftp then do the whole thing that way.

Code: Select all


ftp $1 <<!
user password
mkdir $2
bye
!


It should work on both ways (AIX help)

Posted: Tue Mar 14, 2006 7:29 am
by wvandegaer
kduke wrote:scriptfile mkdir.sh
ftp servername
$ ftpmkdir $1
Does not look right. What is the $ on line 2. In your first post you said this was the command:

Code: Select all

echo "\$ ftpmkd ...[/quote]

the $ on line 2 points at the macrodef in out .netrc file in the home dir of the dsadm user

However it doesn't work on both ways:
1) "echo "\$ ftpmkd .."
2) ". mkdir.sh newdir" with within the script: ftp servername <enter> $ ftpmkdir $1 

Our AIX help does tell us that this are the two ways the automatic ftp-login / script should work.

Re: It should work on both ways (AIX help)

Posted: Wed Mar 15, 2006 5:05 am
by ogmios
I would first make sure the script works outside of DataStage running under the user that would execute the DataStage job.

If you can get it to work like that the problem you're having with DataStage is an "integration" problem.

So can you already make it work outside of DataStage? If it doesn't it's probably more of an AIX support question.

Ogmios