I typically use Python with pexpect to do this sort of thing. The folowing snippet will log on to a Brocade switch, run a command and return the result:
while True: logon_cmd = 'ssh ' + cfg_file.getVal("remote_user") + '@' + remote_host #print 'logon_cmd = ' + logon_cmd child=pexpect.spawn(logon_cmd) i = child.expect(['password:',pexpect.EOF],timeout=10) if i == 1: print "EOF-1 returned" time.sleep(30) continue child.sendline(cfg_file.getVal("remote_pw")) remote_prompt = cfg_file.getVal("remote_prompt") i = child.expect([remote_prompt, pexpect.EOF],timeout=10) #returned_lines = child.after #print returned_lines if i == 1: print "EOF-2 returned" time.sleep(30) continue remote_cmd = cfg_file.getVal("portshow_cmd") #print "remote_cmd = " + remote_cmd child.sendline(remote_cmd) i = child.expect([remote_prompt, pexpect.EOF],timeout=10) if i == 1: print "EOF-3 returned" time.sleep(30) continue returned_lines = child.before child.close();
Thanks, Larry Barber
On Thu, Mar 8, 2012 at 4:30 PM, Don Kuhlman <Don.Kuhlman at schawk.com> wrote:
Hi folks. I've been googling all day, searching the forums, and looking at other spots but obviously I'm doing something wrong.
I'm trying to now setup some customization in Xymon for business applications.
I want to do it either with a homemade script, download, or using built in features.
My first task is to try and login to an ftp server using a test id and password to verify it is up and accepting connections.
Next would be to connect via sFTP and try the same thing.
I'm also trying to do the same kind of tasks with webpages that host applications.
Can someone point me to the best way to do this from our Xymon server, and if there are code snips of how to make an ftp connection, send an ID, Password, and then quit, I would really appreciate knowing where to find them.
Regards,
Don K
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon