Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I send output of the command to my tty ? 2

Status
Not open for further replies.

vptl

Technical User
Jan 22, 2004
120
US
Again....all.
Within the same code....I want to see the output of my command on the screen... here is the code..
system(q!/nas/bin/nas_fs -list | egrep -v 'root|name' | awk '{print $6}'|sed '/^$/d' > /tmp/fs_list!);
open (FS_LIST, "fs_list");
while ( $fs = <FS_LIST> ) {
chomp ($fs) ;
print "$fs\n";
system(q!/nas/bin/fs_replicate -info $fs |egrep current_delta >> /tmp/delta!) ;
}

I do not get error nor see the output.File delta is empty !

any ideas ?

Thanks
 
Your second system function may be the problem.
You want interpolation in this string to expand the "$fs" value out but you're using a single quote to quote the string.
Just change the q! ... ! to qq! ... ! to change from single to double quotes and allow interpolation.

yeah, me again! ;-)


Trojan


 
Redirecting a filehandle to tty you could see the value of $fs...

open(FH,">/dev/tty") || die "open FH:$!";
open (FS_LIST, "fs_list");
while ( $fs = <FS_LIST> ) {
chomp ($fs) ;
print FH "$fs\n";
#system(q!/nas/bin/fs_replicate -info $fs |egrep current_delta >> /tmp/delta!) ;
}

You might check also the full path of fslist..

Cheers


dmazzini
GSM System and Telecomm Consultant

 
Thanks both of you.

I got the output now collected in the file...problem solved.
Just curious....why do I nedd qq I know you did explain..but did not get it.
I know I am asking more here...but this is the way to learn for me.
Once again thanks and really appriciate you help.
 
q" allows you to define a character to use as a single quote, hence the single "q".
"qq" allows you to define a character to use as a double quote, hence the double "q".

Single quoted strings are not interpolated and as such perl treats the string literally and does no processing on it.

Double quoted strings are interpolated and so wherever perl sees a "$" or "@" sign (or even "%") in the string, it tries to replace that character and the following word with the contents of a variable that shares that name.

Your $fs needs to be interpolated (replaced with the contents of $fs) in the last string and so you need interpolation (and therefore double quotes).


Trojan.


 
From Perl How to Program:

q operator surrounds its arguments in single quotes..

Example

'Don\'t cross the street'

q(Don't cross the street)

qq operator surround its argument in double quotes

"Tim asked, \"What time is it?\""

qq(Tim aked,"What time is it?")

dmazzini
GSM System and Telecomm Consultant

 
From the Book, Perl How to Program:

q operator surrounds its arguments in single quotes..

Example

'Don\'t cross the street'

q(Don't cross the street)

qq operator surround its argument in double quotes

"Tim asked, \"What time is it?\""

qq(Tim aked,"What time is it?")

dmazzini
GSM System and Telecomm Consultant

 
understood...Great thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top