November 30th, 2012, 03:46 AM
Hi all i'm newbye
i need to do i little PERL script but i have not study PERL.
i need it in my university thesys... someone can help me??
this is my script but it's incomplete:
#use lib /root/.cpan/build;
my $cmd="show spanning-tree summary | begin vlan";
my $ssh = Net::SSH::Perl->new($host);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
i need the output is saved in a txt file. How i can do???
thank u all for your help.
November 30th, 2012, 12:46 PM
Can't you just print it to a file?
November 30th, 2012, 01:04 PM
Now i have
But i need to save the output in a file before so i can add other comands such as GREP and AWK
November 30th, 2012, 04:20 PM
I do not see:
in your code in the first post.
Where do you have it. Please post a more complete code snippet, at this point seem things seem to be missing.
If you want to print to a file:
1. first open the file
my $outputfile = "result.txt";
open my "$OUT_FH", ">", $outputfile or die "cound not open $outputfile $! \n"
2. Then, whenever you want to print to the file:
print $OUT_FH "whatever you want to print \n";
3. Don't forget to close the file before you try to awk or grep it:
December 1st, 2012, 11:05 AM
Since perl can perform all the functions of grep and awk without calling them, you would probably find it worthwhile to learn the language and do the whole job that way.
Comments on this post