![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl - How to print a "carriage return" to an output file? | teiji | Shell Programming and Scripting | 5 | 03-06-2009 03:44 AM |
| capturing output from top and format output | new2ss | Shell Programming and Scripting | 4 | 02-24-2009 09:26 PM |
| How to print log file in column format using awk | suresh3566 | Shell Programming and Scripting | 2 | 05-06-2008 02:18 PM |
| Check for proper e mail id format | prolay | Shell Programming and Scripting | 2 | 08-23-2007 05:37 AM |
| How to print current month - 1 in string format | mogli4 | Shell Programming and Scripting | 3 | 03-10-2006 04:47 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Net::SSH::Perl ...... how to print the output in a proper format
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 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 drwxr-xr-x 2 readonly bin 4096 Apr 9 2008 s -rw-r--r-- 1 readonly bin 14739 Jul 17 2008 Analysis_07172008_Run2 -rw-r--r-- 1 readonly bin 15152 Jul 16 2008 17_07_2008 Please anyone let me know your valuable suggestions to display the o/p 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 drwxr-xr-x 2 readonly bin 4096 Apr 9 2008 s -rw-r--r-- 1 readonly bin 14739 Jul 17 2008 Analysis_07172008_Run2 -rw-r--r-- 1 readonly bin 15152 Jul 16 2008 17_07_2008 Not only for 'ls' command, but executing any commands using Net::SSH::Perl connection displays the output as a single line. Please let me know your valuable suggestions. Thanks in Advance |
|
||||
|
Yes, you are right which is expected.
But 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 Last edited by gsprasanna; 04-27-2009 at 10:25 AM.. |
|
||||
|
Though at present i am having a solution where we can split the output of 'ls' command as the output 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 the output. i.e 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 drwxr-xr-x 2 readonly bin 4096 Apr 9 2008 s But this is just a temporary solution which works fine for 'ls -l' command. But tomorrow if we wish to execute other commands such as "ls", "cat" and so on... it wont work. But i appreciate 4ur thoughts & ur precious time..... Still lets hope for a solution where we can print the output in a format wrapped at every newline of output and display the same on a browser. Thanks in Advance, GS |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|