unix command execution issue

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
dr.murthy
Participant
Posts: 224
Joined: Sun Dec 07, 2008 8:47 am
Location: delhi

unix command execution issue

Post by dr.murthy »

Hi,

I have an unix command its executinf fine in unix editor but when i tried to execute same command in datastage through execute command activity its throwing below warning

SH: -c: line 0: unexpected token 281 in conditional command
SH: -c: line 0: expected `)'
SH: -c: line 0: syntax error near `(28801>'
SH: -c: line 0: `if [[ $(ls -tr /etl/dev/target_files/work_files/spd_pyxis_adm/touch_files | wc -l) > 3 ]];then if [[ (T != "S") && (28801>=28800) && (28800<=72000)]];then echo "Source File Is Not Available " | mail -s "Hourly load job seq_Hourly_SPD_PYXIS_ADM:" XXX@yyy.com -r yyy@fff.com; fi;fi;'


provide some suggestions ..
D.N .MURTHY
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Suggest you show us your script.
-craig

"You can never have too many knives" -- Logan Nine Fingers
virtusadsuser
Premium Member
Premium Member
Posts: 16
Joined: Thu Jan 12, 2012 2:10 am
Location: India

Post by virtusadsuser »

Hi,

Please look at this below unix command "
if [[ (28800<=72000) ]];then echo "Source File Is Not Available " | mail -s "Hourly load job seq_Hourly_SPD_PYXIS_ADM:" xxx@yyy.com -r dsadmd@yyy.com; fi;"

this command executing fine in unix environment , but when i tried to execute it through datastage in execute comand activity its saying below warnings .

SH: -c: line 0: unexpected token 281 in conditional command
SH: -c: line 0: expected `)'
SH: -c: line 0: syntax error near `(28800<'
SH: -c: line 0: `if [[ (28800<=72000) ]];then echo "Source File Is Not Available " | mail -s "Hourly load job seq_Hourly_SPD_PYXIS_ADM:" xxx@yyy.com -r dsadmd@yyy.com; fi;'
Dream...Dare...Do
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If you are going to use specific shell syntax (looks like Korn to me) then try specifying that in the Execute Command stage by prefixing it with the shell. So perhaps "ksh if..." might help. Use whatever shell you've coded for.
-craig

"You can never have too many knives" -- Logan Nine Fingers
aartlett
Charter Member
Charter Member
Posts: 152
Joined: Fri Apr 23, 2004 6:44 pm
Location: Australia

Post by aartlett »

I thibnk:
SH: -c: line 0: syntax error near `(28801>'

is a clue. Looks like you need a space between the variable that is reprresented by 28801 and the >.

and Craig's suggestion is valid, DS executes basic sh commands and a lot of 'nix's don't . Most are either bash or ksh and you need to specify them to get things to work.

It it is working in the command line, find what shell you are executing and prefix the command there.
Last edited by aartlett on Tue Mar 20, 2012 7:00 pm, edited 1 time in total.
Andrew

Think outside the Datastage you work in.

There is no True Way, but there are true ways.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

I agree you probably need to surround your operators with spaces. Also test it from the command line itself before pasting it into DataStage.
Choose a job you love, and you will never have to work a day in your life. - Confucius
PaulVL
Premium Member
Premium Member
Posts: 1315
Joined: Fri Dec 17, 2010 4:36 pm

Post by PaulVL »

Your ticky marks look off to me.

I can't even make one it's suppose to be on my iPod touch.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Good point... The first mark is a tick and the last mark appears to be a single quote, which are different. I don't think you would want to use tick marks in this example.
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I believe the backquote and upright quote are an artifact of the error report, and unlikely to be in the script itself.

Who writes stuff like that anyway?!!
:evil:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Issue aside, is the following

Code: Select all

$(ls -tr /etl/dev/target_files/work_files/spd_pyxis_adm/touch_files | wc -l) > 3
going to give what you want? You are only ever going to get one "/etl/dev/target_files/work_files/spd_pyxis_adm/touch_files" file back from the ls so would imagine "wc -l" will only ever give 1.

Should it be "touch_files*" or a wc on the content of "touch_files"?
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

And may as well not list the file (or files?) by time order if the only purpose is to capture a line count.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Post Reply