how to supress - no such file or directory unix error

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
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

how to supress - no such file or directory unix error

Post by Marley777 »

Hi, thanks for reading. I have a datastage job with a routine activity step. In the routine activity I use the following

"ls -1u /blah/blah/blah/FILENAME*.txt > /blah/blah/blah/FILENAME2.txt"

If FILENAME*.txt isn't found I get the 'no such file or directory error'. It is very common to not have a file in our situation. Can someone please show me how to modify the 'ls' command so that the error message is suppressed and the datastage job doesn't abort?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Typically one would redirect standard error to /dev/null.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

I have tried this

"ls -1u /blah/blah/blah/FILENAME*.txt > /blah/blah/blah/FILENAME2.txt > /dev/null"

and

"ls -1u /blah/blah/blah/FILENAME*.txt > /blah/blah/blah/FILENAME2.txt > 2 /dev/null"

but still get the error

/blah/blah/blah/FILENAME*.txt not found

do I need to change where/how I use "/dev/null' ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Code: Select all

ls -1u /blah/blah/blah/FILENAME*.txt > /blah/blah/blah/FILENAME2.txt 2>/dev/null
-craig

"You can never have too many knives" -- Logan Nine Fingers
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Hi I gave it a shot, the DS sequencer still aborts. Looks like DS still knows somehow that the command could not find the file. Any other ideas are greatly appreciated.

rtneCreateList (ROUTINE DSU.ExecSH) started
13:05:33: rtneCreateList finished, reply=1
13:05:33: Exception raised: @rtneCreateList, Unhandled failure (1) encountered calling routine DSU.ExecSH
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DataStage detects the exit status. You can generate a fake exit status of 0 to prevent the warning. But... what do you then want DataStage to do in the case that the file does not exist?

Code: Select all

ls -1u /blah/blah/blah/FILENAME*.txt > /blah/blah/blah/FILENAME2.txt 2>/dev/null ; echo ""
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, should have been more specific - that suppresses the message but as noted you still have to handle the non-zero return status rather than leave it "unhandled". That's an option you turned on in the Sequence job and you can override that behaviour by handling the error yourself. Simplest way to make it see that you are handling any problems is with two triggers from the stage: an "OK" and an "Otherwise" trigger. If you don't care that it found no files then simply run both to a Sequencer set to Any before going on to the next step.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply