Sponsored Content
Top Forums Shell Programming and Scripting Net::SSH::Perl ...... how to print the output in a proper format Post 302310825 by gsprasanna on Monday 27th of April 2009 06:41:20 AM
Old 04-27-2009
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check for proper e mail id format

Hi, We run an application called meta which reads user information from database and updates in LDAP.For that we have some scripts to check the uniqueness of mail ids between the existing LDAP and Database.It works fine when people enter mail ids in proper format (xxx.yyy@abc.com) but if it... (2 Replies)
Discussion started by: prolay
2 Replies

2. Shell Programming and Scripting

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 my $cmd = "ls -l"; 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... (2 Replies)
Discussion started by: gsprasanna
2 Replies

3. Shell Programming and Scripting

Output file not displayed in the proper format

Hi am using uuencode fro attaching one report which is nothing but sql query output. But when i receive the report through attachement and when it is opened the report is not displayed in proper format. Means if the sql query has 100 rows the mail attachment report displays the report in 2... (2 Replies)
Discussion started by: weknowd
2 Replies

4. Shell Programming and Scripting

Getting Proper Date Format in SH Script

There's a small SH script I'm trying to write where it will get the current month and find a log file that is based on the date. Example: Today is February, so the log file is going to be 201102.log (2011 + 02) An additional thing is that if today is the 1st of a month, it will also find the log... (3 Replies)
Discussion started by: kooshi
3 Replies

5. Shell Programming and Scripting

Net::SSH::Perl slow to login.

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)
Discussion started by: mrwatkin
2 Replies

6. Shell Programming and Scripting

Need to split a xml file in proper format

Hi, I have a file which has xml data but all in single line Ex - <?xml version="1.0"?><User><Name>Robert</Name><Location>California</Location><Occupation>Programmer</Occupation></User> I want to split the data in proper xml format Ex- <?xml version="1.0"?> <User> <Name>Robert</Name>... (6 Replies)
Discussion started by: avishek007
6 Replies

7. Shell Programming and Scripting

how to format ssh top output

Hello; Am trying to generate runaway proc report using ssh thusly: =================== ssh -t -t $BOX 'TERMINAL="vt100" top -d1 -h -n 10' >> $FILE . . cat $FILE | mail -s "Latest Top `date`" $MAIL_TO ==================== But the output to e-mail comes out rather garbled .. Any ideas... (1 Reply)
Discussion started by: delphys
1 Replies

8. Shell Programming and Scripting

Read from text file;format and print output

Hi Following is the assumed input... Symmetrix ID : 12345 Originator Port wwn : 123456789 User-generated Name : 123456789/123456789 Sym Dev Dir:P LUN ------ ----- ----------------------- ---- --- ---- ---- ---- ------- 1234 ... (4 Replies)
Discussion started by: maddy.san
4 Replies

9. Shell Programming and Scripting

Combine multiline to one line with proper format

Hello Guys, I have a file say FILE1.txt contains below data:- A B C D E F G H I J K L I need the output in another file as FILE2 as:- 'A', 'B', 'C', 'D', 'E', (7 Replies)
Discussion started by: jassi10781
7 Replies

10. UNIX for Beginners Questions & Answers

Convert rows to column and print output in required format

Hi All, i am trying to print the solaris 11 packages in below required format, But i am unable to do that. Current ouput : root@abc# pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' NAME: QLogic 570x/571x Gigabit Ethernet Driver VERSION: 11.11,REV=2009.11.11 ... (7 Replies)
Discussion started by: balu1234
7 Replies
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/ksh93 /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/ksh93 /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/sfw/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. NOTES
Restricted shells should not be listed in /etc/shells. SunOS 5.11 1 Nov 2007 getusershell(3C)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy