Page 1 of 1

DSJob command to a variable

Posted: Tue Sep 04, 2007 11:59 am
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.....

Re: DSJob command to a variable

Posted: Tue Sep 04, 2007 1:48 pm
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?

Re: DSJob command to a variable

Posted: Tue Sep 04, 2007 2:43 pm
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,

Re: DSJob command to a variable

Posted: Tue Sep 04, 2007 2:48 pm
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"

Posted: Tue Sep 04, 2007 8:07 pm
by kduke
Why would you want to do this? This may not work in the next release.