473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Not able to print the variable in which popen result of a remote m/c is stored.

Expand|Select|Wrap|Line Numbers
  1. port2_result=os.popen('ipmitool raw 0x3a 0x11 0x2a 0x6f 0x00 8').read()
this is the expression i've written in a script after calling a procedure to establish SSH connection to a remote machine. the same thing works for local machine but after ssh, it's giving the variable as '[ ]'. the ssh procedure is as follows:
Expand|Select|Wrap|Line Numbers
  1. def SSH (user,host,PROMPT) :
  2.     os.system('rm -f /root/.ssh/known_hosts')
  3.     SSHd = 'ssh '+user+'@'+host
  4.     ssh_obj = pexpect.spawn(SSHd)
  5.     try :
  6.         ssh_obj.logfile=None;
  7.         ssh_obj.expect('\(yes\/no\)\?',timeout=50)
  8.         ssh_obj.sendline('yes')
  9.     except :
  10.         print "Unable to login to "+host
  11.         sys.exit(3)
  12.     try:
  13.         ssh_obj.expect(PROMPT,timeout=50)
  14.     except:
  15.         print "Unable to login to "+host
  16.         sys.exit(3)
  17.     try:
  18.         ssh_obj.sendline('XYZ')
  19.         ssh_obj.expect('found',timeout=10)
  20.         ssh_obj.sendline('PS1="RTM_SHOW>"')
  21.         ret=ssh_obj.expect(['RTM_SHOW>','#'],timeout=5)
  22.         if ret == 1:
  23.             ssh_obj.expect('RTM_SHOW>',timeout=5)
  24.     except:
  25.         print "Unable to change Prompt"
  26.         sys.exit(3)
  27.     ssh_obj.logfile=sys.stdout;
  28.     return ssh_obj
  29.  
and this is where i'm executing the command
Expand|Select|Wrap|Line Numbers
  1. if node != host :
  2.     print "YES",
  3.     try:
  4.         local=SSH("root",node,'#')
  5.         local.logfile=sys.stdout
  6.     except:
  7.         print "unable to do SSH."
  8.  
  9.  
  10.     try:
  11.               # reg=re.compile(r'^\s\d.+')
  12.                reg=re.compile('.*')
  13.                print "cmdsend"
  14.                local.sendline('ipmitool raw 0x3a 0x11 0x2a 0x6f 0x00 7')
  15.                ret=local.expect([reg,'RTM_SHOW>'],timeout=15)
  16.                if ret == 0:
  17.                    port1_result=local.match.group()
  18.                    print "my",port1_result
  19.                else:
  20.                         sys.exit(1)
  21.  
  22.  
  23.                port2_result = os.popen('ipmitool raw 0x3a 0x11 0x2a 0x6f 0x00 8').read()
  24.                parse_output(port1_result,port2_result)
  25.     except:
  26.                print "error EXECUTING ssh commands."
  27.  
its printing "error EXECUTING ssh commands." the ret value is 0. I don't know how to check what is it actually printing on that remote machine!! pls help!
Jan 22 '11 #1
0 1469

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael Krasnyk | last post by:
Hi, How can I print variable values by their names? For example: import sys for str in dir(sys): print str Will be printed only variable names, but I need values from list of variable...
0
by: Charley | last post by:
Hi, My local procedure needs to call a remote stored procedure which dblink name is built at the run time depending on the input parameter to the local procedure. Therefore depending on the...
4
by: Greg | last post by:
I need to send the result of a procedure to an update statement. Basically updating the column of one table with the result of a query in a stored procedure. It only returns one value, if it didnt...
0
by: Kolar | last post by:
1.. EXEC sp_addlinkedserver ServerName1, N'SQL Server' EXEC sp_addlinkedserver ServerName2 EXEC sp_configure 'remote access', 1 RECONFIGURE GO 2.. Stop and restart the first SQL Server. 3.....
2
by: Bill_DBA | last post by:
I have the following stored procedure that is called from the source of a transformation in a DTS package. The first parameter turns on PRINT debug messages. The second, when equals 1, turns on the...
0
by: KAData | last post by:
I have a program that will access remote stored procedures via visual basic.net application. I have SQL Server Management Studio Express (2005) installed on the client computers that will be...
3
by: thanawala27 | last post by:
Hi, I would like to seperate a variable which has '.' (dot) as the delimiter using the split function. $var1 = "first.second"; @value = split(/./, $var1); then the value of $value should...
2
by: Chronos | last post by:
Hi all, Is it possible to print text file to a remote printer in C#? If so, can you tell me how? Thanks, Chronos
0
by: Blubaugh, David A. | last post by:
To All, Has any one out there ever worked with the Rpyc, which is a remote process call for python? David Blubaugh
1
by: sanjasmine | last post by:
Is it possible to subtract a few hours from the variable which shows date in UTC format
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.