DSJob command to a variable

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

DSJob command to a variable

Post by g_rkrish »

Hi
I am doing one script in which am trying to put the linfo i.e the number of records of a file into log file so what i did was i did the ds job command and did a grep and cut command to get the num of records and here is my command

dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30

It works fine...

But my requirement is i need to append to a file in specified format ... so it shopuld be like
for ex:

Records : 72222

so what i did was i did like

print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename

it not doing anyhting...

so i itred to put into a variable say

set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `

and do like printf 'Records : $var1' >> myfile.txt

it not doing any thing either the funny part is am not geeting any error either..Pls help me out.....
RK
Ultramundane
Participant
Posts: 407
Joined: Mon Jun 27, 2005 8:54 am
Location: Walker, Michigan
Contact:

Re: DSJob command to a variable

Post by Ultramundane »

g_rkrish wrote:Hi
I am doing one script in which am trying to put the linfo i.e the number of records of a file into log file so what i did was i did the ds job command and did a grep and cut command to get the num of records and here is my command

dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30

It works fine...

But my requirement is i need to append to a file in specified format ... so it shopuld be like
for ex:

Records : 72222

so what i did was i did like

print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename

it not doing anyhting...

so i itred to put into a variable say

set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `

and do like printf 'Records : $var1' >> myfile.txt

it not doing any thing either the funny part is am not geeting any error either..Pls help me out.....
print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename
- This is not valid because you are passing the string Records: into the program dsjob.


set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `
- This depends on what shell you are using.


printf 'Records : $var1' >> myfile.txt
- You used single quotes.


What shell are you using? Do you want the string in variable or would simply using awk to add the "Recods: " suffice?
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Re: DSJob command to a variable

Post by g_rkrish »

Ultramundane wrote:
g_rkrish wrote:Hi
I am doing one script in which am trying to put the linfo i.e the number of records of a file into log file so what i did was i did the ds job command and did a grep and cut command to get the num of records and here is my command

dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30

It works fine...

But my requirement is i need to append to a file in specified format ... so it shopuld be like
for ex:

Records : 72222

so what i did was i did like

print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename

it not doing anyhting...

so i itred to put into a variable say

set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `

and do like printf 'Records : $var1' >> myfile.txt

it not doing any thing either the funny part is am not geeting any error either..Pls help me out.....
print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename
- This is not valid because you are passing the string Records: into the program dsjob.


set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `
- This depends on what shell you are using.


printf 'Records : $var1' >> myfile.txt
- You used single quotes.


What shell are you using? Do you want the string in variable or would simply using awk to add the "Recods: " suffice?
I am using korn shell...... also i tried with the double qutoes it is not doing any thing for the var1.....

Thanks,
RK
Ultramundane
Participant
Posts: 407
Joined: Mon Jun 27, 2005 8:54 am
Location: Walker, Michigan
Contact:

Re: DSJob command to a variable

Post by Ultramundane »

g_rkrish wrote:
Ultramundane wrote:
g_rkrish wrote:Hi
I am doing one script in which am trying to put the linfo i.e the number of records of a file into log file so what i did was i did the ds job command and did a grep and cut command to get the num of records and here is my command

dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30

It works fine...

But my requirement is i need to append to a file in specified format ... so it shopuld be like
for ex:

Records : 72222

so what i did was i did like

print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename

it not doing anyhting...

so i itred to put into a variable say

set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `

and do like printf 'Records : $var1' >> myfile.txt

it not doing any thing either the funny part is am not geeting any error either..Pls help me out.....
print 'Records :' | dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 >> filename
- This is not valid because you are passing the string Records: into the program dsjob.


set var1 = `dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30 `
- This depends on what shell you are using.


printf 'Records : $var1' >> myfile.txt
- You used single quotes.


What shell are you using? Do you want the string in variable or would simply using awk to add the "Recods: " suffice?
I am using korn shell...... also i tried with the double qutoes it is not doing any thing for the var1.....

Thanks,
That's because set is not doing what you expect. In Korn Shell "set" is used to create arrays or set certain session settings.

Get rid of the set and just do (make sure you no spaces before or after '='):
var1=`dsjob -linkinfo Projectname Jobanme stagename Linkname | grep 'Link Row Count'| cut -c18-30`

print "Records : $var1"
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Why would you want to do this? This may not work in the next release.
Mamu Kim
Post Reply