Page 1 of 1

unix command execution issue

Posted: Tue Mar 20, 2012 6:37 am
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 ..

Posted: Tue Mar 20, 2012 8:00 am
by chulett
Suggest you show us your script.

Posted: Tue Mar 20, 2012 8:06 am
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;'

Posted: Tue Mar 20, 2012 9:31 am
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.

Posted: Tue Mar 20, 2012 6:54 pm
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.

Posted: Tue Mar 20, 2012 6:58 pm
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.

Posted: Tue Mar 20, 2012 7:41 pm
by PaulVL
Your ticky marks look off to me.

I can't even make one it's suppose to be on my iPod touch.

Posted: Tue Mar 20, 2012 7:45 pm
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.

Posted: Tue Mar 20, 2012 8:50 pm
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:

Posted: Tue Mar 20, 2012 8:58 pm
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"?

Posted: Tue Mar 20, 2012 10:00 pm
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.