Weird problem with command activity

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
gaurang033
Participant
Posts: 26
Joined: Mon Oct 17, 2011 6:00 am

Weird problem with command activity

Post by gaurang033 »

Hi All,

I have a shell script which i am calling from command activity, the script gives desired output when i run from Shell but it behaves weird when i call it from command activity.

I debug the script and figure it out that there is a particualr part in script which bahevs unexpected when i call it from command acitivity..

Code: Select all

 name=$1
output=`ls $1`
echo $output
When i call this script from shell like follows it list all the file with same pattern.

Code: Select all

 sh findFiles.sh "aa*1" 
but when i call same script with command output with same parameter it gives following output

aa*1 not found

Now i am not able to understand why this is happening. Any suggestion ???
gaurang033
Participant
Posts: 26
Joined: Mon Oct 17, 2011 6:00 am

Re: Weird problem with command activity

Post by gaurang033 »

this is also not working.

Code: Select all

 echo $1
if i will call above script like as below, it will list all the files

Code: Select all

sh findFiles.sh "aa*1"
However if i call same script with same parameter from Execute command it prints only following line
aa*1
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

It might be the issue with relative directory. When running the comman, from which directory do you run it.

When calling from the DS, are you sending directory name along with the pattern? Add pwd command in the script and see what directory it prints.
Regards,
S. Kirtikumar.
gaurang033
Participant
Posts: 26
Joined: Mon Oct 17, 2011 6:00 am

Post by gaurang033 »

no there is no problem with the path. i copy the command generated by sequence from log and run on shell and it gives output.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

May i know how you are calling in Execute Command activity stage?

What you are giving in command and parameters?
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

gaurang033 wrote:no there is no problem with the path. i copy the command generated by sequence from log and run on shell and it gives output.
FYI - this doesn't really prove anything, you could still have a path issue in the job. The only way to avoid that is to use an absolute path in the stage.

To me it seems like the quotes are being stripped... escape them.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mark1024
Participant
Posts: 9
Joined: Mon Nov 07, 2011 12:23 pm

Re: Weird problem with command activity

Post by mark1024 »

Think about what the Shell is doing, "aa*1" the shell is trying to figure out what the star means, try putting a "aa\*" . I know in bash the special chars get processed if you don't put a slash in them.
Mark THomas
Data Architect
IBM GBS
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Yes! Mark's Suggestion is appropriate!!
pandeeswaran
Post Reply