Extracting files from unix

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

Moderators: chulett, rschirm, roy

chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Close... you need to create a job parameter in 'job 2', use it for the filename and then assign $CommandOutput to that parameter in the Job Activity stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Getting error below

seq_all calls job1 and job2

job1 return 0
Output from command ====>
/aa/test/aa_201005051223400386_test1.csv

so for job2
Under job properties i gave parameter name input_file_name string default value blank

Then under seq_all for job2 job actvity for parameters name input_file_name i gave expression value "job1.$CommandOutput"

I am getting error (for job2)

$CommandOutput : No such file or directory.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

times29 wrote:Then under seq_all for job2 job actvity for parameters name input_file_name i gave expression value "job1.$CommandOutput"
Did you type that in by hand or use the External Parameter Helper to populate it for you? If the former, do the latter.
-craig

"You can never have too many knives" -- Logan Nine Fingers
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

In the job where you want to read the file using seq file stage, use a parameter say "xxx" and you set the file name in seq file stage as <path>/#xxx#.

And in the sequencer where you set the values for parameters of the job you set the value for xxx=$CommandOutput
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Again, close. In the Sequence's Job Activity, you set the value of the parameter to ExecuteStageName.$CommandOutput which is what the helper would build for you. With the appropriate stage name substituted in, of course.

The next issue will be the fact that the parameter's value will be 'inappropriate' because of the @FM / Field Marks in the returned dynamic array. However, that's been asked and answered so many times here that a reasonable search should turn the full answer up rather easily.
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

JobControl (@job1): Executed: ls -1 test/aa/*.csv | sort -nt_ -k2.1,2.6 | tail -1
Reply=0
Output from command ====>
test/aa/test_201005051223400386_test.csv
---------------this step is good now while passing this value to job2 i am getting error file not found

job1 -> (Src_xxx): Job run requested
Mode (row/warn limits) = 0/0
Job Parameters --->
$DATA_DIR=/opt/IBM/InformationServer/aa/Data/
OUTPUT_FILE_NAME=tmp_xxx
INPUT_FILE_NAME=XXX=$CommandOutput ---------------(Issue with this command)
DSJobController=job1
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Answer this:
chulett wrote:Did you type that in by hand or use the External Parameter Helper to populate it for you? If the former, do the latter.
The "helper" is under the ellipsis (...).
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

ellipsis (...).
deeplind07
Participant
Posts: 31
Joined: Mon Jun 28, 2010 5:15 am
Location: pune

Post by deeplind07 »

Hi,
This is the first time i am posting anything on DSex.

1. Cat > Latest_file.sh
cp `ls -1 *.csv | sort -n -t"_" -k 2.1,2.6|tail -1` Latest_file.csv

2. Call this .sh file in the before job sub routine or in an execute command stage.

3. Then in the file stage add file name=Latest_file.csv

PLease let me know if this helped. :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I guess we'll see... hopefully by now they've got it sorted out, however. :wink:
-craig

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