problem with FTP Script

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

sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

problem with FTP Script

Post by sheema »

I have a Sequence where i am using a Execute Command Stage through which i am calling a script to FTP a file from local path to a remote server.
I am passing the following parameters to the script
localpath
localfile
remoteserver
remoteuser
remotepassword
remotepath.

when i execute the sequence,the output for the Execute Command is below

Reply=0
Output from command ====>
XXX: A file or directory in the path name does not exist.

This XXX is the localfile which i need to FTP to the remote server.


When i replace the localpath parameter and hard code the path of XXX in the script it is working fine.

Can any one let me know,what the problem would be.
Thanks

Sheema
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Re: problem with FTP Script

Post by narasimha »

sheema wrote:When i replace the localpath parameter and hard code the path of XXX in the script it is working fine.
Looks like you have some problem while referencing the parameters in the script.
Post the script if you can.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

The script is as below

remote_server="${1}"
remote_user="${2}"
remote_passwd="${3}"
remote_path="${4}"
remote_file="${5}"
local_path="${6}"
local_file="${7}"
log_path="${8}"


ftp -v -n $remote_server << eof >> $log_path/$local_file.log
user "$remote_user" "$remote_passwd"
lcd $local_path
cd $remote_path
prompt
put $local_file $remote_file
eof
Thanks

Sheema
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What's your DataStage version?
-craig

"You can never have too many knives" -- Logan Nine Fingers
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

Datastage 7.5
Thanks

Sheema
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

1. Make sure you are passing the same value in the Job Properties which you have hardcoded in the script and ran successfully.
2. Check if your local_path default value has any spaces in it?
3. Also you might want to echo all commands and collect them in the local_file.log so that it will be more helpful while debugging. You can figure out how each command was executed.
Kris

Where's the "Any" key?-Homer Simpson
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

I am passing the same Path which i have hard coded.I have checked that.
Thanks

Sheema
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

What about spaces in the default local_path??
Kris

Where's the "Any" key?-Homer Simpson
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

No,it does not have any spaces.
Thanks

Sheema
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How exactly are you passing these parameters to the script? Can you post what you have in the Parameter box of the Execute Command stage?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Ok. Now the last thing I can suggest is it might be a permissions issue. Talk to your sysadmin and make sure that the user who is running the datastage job has full access to all the folders within the path. I know you were able to run it while you were hardcoding the full path, but I don't think it is the same as passing the parameters. Last time that happened to me, it was both spaces and then finally permissions issue. So, first check out by yourself if you can drill down to the XXX file right from the C: drive or whereever the file is. If it still continues, we still have to do some thinking.

edited to add: Also, along with what Craig has asked, post what you have in the command window too. who knows!!
Kris

Where's the "Any" key?-Homer Simpson
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

This is text which i have in the parameter box

#FTPServer# #FTPUser# #FTPPwd# #FTPPath# #FTPFile# #localpath# #localfile# #logpath#
Thanks

Sheema
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thanks, wanted to make sure they were properly 'wrapped'.

The reason I asked for your DS version is there is a very well known 'issue' with job parameters in the Execute Command stage. In 'older' versions it will log the translated command correctly, but actually pass the untranslated job parameters to your script.

If you have the base version of 7.5 then you probably are having this issue. It seems to be corrected in the 7.5.1A version, so if that's what you are running then something else may be going on. In either case, I'd suggest you have your script log what it is getting in the way of parameter values so you can diagnose what's going on.

If that is your problem, the 'work around' is to replace the Execute Command stage with a Routine Activity stage that executes the script via the DSExecute function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

I have done the same thing on 7.5, but on Windows, successfully Craig. So, I don't think it should be any different on Unix and is an issue with this base version. However, logging the script is a good practice which is how I debugged my issues and suggested in my earlier post.

I have a question though for sheema. How are you passing the script to this job? Is it in the command window? If so are you hardcoding the fullpath for the script or did you place the script in the default folder?
Last edited by kris007 on Wed Aug 09, 2006 12:31 pm, edited 1 time in total.
Kris

Where's the "Any" key?-Homer Simpson
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

Thanks for the reply,I will try both the options which you mentioned.

But can you be little elaborate on how to use Routine Activity stage that executes the script via the DSExecute function. I have never worked on this earlier
Thanks

Sheema
Post Reply