Page 1 of 1

execute shell command

Posted: Wed May 15, 2002 3:26 pm
by DSGuru
I tried to invoke rm on Unix from datastage to clean up temp files, but it didn't work. The temp files were created on the fly using parameters. In the job sequencer, we're able to use the execute command stage. The stage requires two things, command name, and parameter. If I want to execute rm #tempfold#/#tempname_todaydate#.txt, how do I do it???

Thank you very much in advance.



Leonardo da Vinci

Posted: Wed May 15, 2002 3:52 pm
by chulett
Not having used the Sequencer, I would *guess* it would simply be a matter of using "rm" as the command name (or you may need to fully path it to be safe) and then using "#tempfold#/#tempname_todaydate#.txt" as your "parameters". Another issue could be a permissions problem, so you might also want to consider using the "-f" option... now, whether it matters if that option goes with the command or parameters, I don't know.

-craig

Posted: Wed May 15, 2002 4:13 pm
by DSGuru
I used absolute path, the permission shows it's mine.
jobtesting..JobControl (@rm_Tempfiles): Executed: "rm /usrs/username/temp/tempfile1.txt /usrs/username/temp/tempfile2.txt"
Reply=2
Output from command ====>
usage: rm [-efirR] file ...

You can see there is not much of info for me to debug.

I've found that DataStage is not very robust and extremely poor on error message and help file.


Leonardo

Posted: Wed May 15, 2002 5:08 pm
by chulett
I've typically found that DataStage is very robust, and has excellent online help. In this case, I think you've found a bug. I played with a Sequence job for the first time, one that did nothing other than execute the "rm" command. It failed, just as you described, no matter how I arranged the command or parameter parts. I *finally* got it to work by 'hard coding' the Job Parameter values into the parameters line. Both ways show the same command being executed ("rm /xxxx/yyyy/a.txt")in the log, but the version using Job Parameters just don't work, while the hard coded version works fine. I'd report it to Ascential Support.

-craig

Posted: Thu May 16, 2002 7:07 am
by DSGuru
Thank you very much for your help Craig.

Posted: Thu May 16, 2002 9:22 pm
by vmcburney
This is a known defect in 5.1, the execute stage does not allow the use of job parameters in the execute parameter field. The work around is to use a routine stage, pass it the command and parameters and run the command from the routine. This has the advantage of centralising your execute code so you can reuse error handling.