Net::SSH::Perl->Execute any unix command & display the output in a proper form
Net::SSH::Perl ...... how to print the output in a proper format
the script works fine, but i am unable to see the output getting displayed in a correct format.
i.e output of the above script is as follows:
total 79936 -rw-r--r-- 1 readonly bin 306 Feb 13 2008 a1.sh -rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog1.sh -rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog2.sh -rw-r--r-- 1 readonly bin 1248 Feb 13 2008 ca.log -rw-r--r-- 1 readonly bin 38143 Jul 17 2008 17072008_Run2 drwxr-xr-x 2 readonly bin 4096 Apr 9 2008 s -rw-r--r-- 1 readonly bin 14739 Jul 17 2008 07172008_Run2 -rw-r--r-- 1 readonly bin 15152 Jul 16 2008 17_07_2008
Instead of displaying the output as,
total 79936
-rw-r--r-- 1 readonly bin 306 Feb 13 2008 a1.sh
-rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog1.sh
-rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog2.sh
-rw-r--r-- 1 readonly bin 1248 Feb 13 2008 ca.log
Though at present i am having a solution where we can split the output of 'ls' command i.e $stdout which will be of this format...
-rw-rw-rw- 1 root dir 104 Dec 25 19:32 filename
we can split the above output as fields i.e at filename field and we can assign this to an array and there by we can print/read the array. Which will print as follows
total 79936
-rw-r--r-- 1 readonly bin 306 Feb 13 2008 a1.sh
-rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog1.sh
-rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog2.sh
But this is just a temporary solution which works fine for 'ls -l' command. But if we wish to execute any other commands such as "ls", "cat" and so on... it wont work, i mean again the output of these "ls", "cat" will be in improper format.
i am looking for some way/solution where we can print the output { as if executing a command in a unix box displays the output in a clear format.} At present i am using CGIPerl Script to display the output on a browser and i am able to print the output on a browser in this way ....
total 79936 -rw-r--r-- 1 readonly bin 306 Feb 13 2008 a1.sh -rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog1.sh -rw-r--r-- 1 readonly bin 216 Oct 11 2007 accesslog2.sh -rw-r--r-- 1 readonly bin 1248 Feb 13 2008 ca.log -rw-r--r-- 1
Thanks in Advance, GS
Last edited by Yogesh Sawant; 05-06-2009 at 06:44 AM..
Reason: added code tags
Hi,
I am having nightmare issue-ing remote ssh command from a CGI perl script.
It just won't run on debug message: It says permission denied. Can I even do this? as the apache server running under DAEMON account probably can't execute it? Is this the case of what's going on?
Here is my... (3 Replies)
Hi folks,
Please advise which command/command line shall I run;
1) to display the command and its output on console
2) simultaneous to save the command and its output on a file
I tried tee command as follows;
$ ps aux | grep mysql | tee /path/to/output.txt
It displayed the... (7 Replies)
Hi Guys,
my $cmd = "ls -l"; #........ {or let it be as # my $cmd= "ls"; }
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd("$cmd");
print $stdout;
the script works fine, but i am unable to see the output getting displayed in a... (7 Replies)
I have some sample code that's supposed to ssh to another machine using Net::SSH::Perl, execute a command, and print
the output of that command. It's very basic, and it works. However, I noticed that upon logging in:
$ssh->login('username','password');
It takes roughly 10-13 seconds to... (2 Replies)
Am trying to lean perl scripting in Unix OS to automate my tasks.
Please find the below perl script i have tried
#!/usr/bin/perl -w
print "Please Enter the VG name to be checked:";
$A = <>;
print "Please Enter the free size to be checked in GB:";
$B = <>;
$vgcheck = `vgdisplay... (7 Replies)
Hi I have a perl command that doesn't seem to be working correctly. It appears to be fine but even when i try and run it manually same thing. Can someone take a look at this and tell me what they think the problem could be?
Here is the perl Line:
system ("echo 'ssh -t -t $user\@$_ \"cd... (3 Replies)
My .NET website invokes a perl script to perform GIT operations on Gerrit server running UBuntu. In the perl script I connect using passwordless authentication to Gerrit server as below:
system ( "ssh gitadmin@gerritserver.com 'cd /xyz && git clone xxx' ");
I verified that ssh authentication... (3 Replies)
Hello All i have a KSH script which basically takes attribute name as input argument and searches whole Netezza appliance and prints information of where that column is used (Table/Views) etc.
Problem with this approach business users have to raise SUDO access request, Install Putty, run through... (1 Reply)
Hello i am having an issue with bash script and this is the code
now=$(cat hosts1.txt | awk '{print $2;}')
while read n ;do
ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers'
When i execute only part with cat, it... (8 Replies)