source:
CMTManagement/utils/sshls.py
Last change on this file was 421, checked in by , 17 years ago | |
---|---|
|
|
File size: 423 bytes |
Line | |
---|---|
1 | #!/usr/bin/env python |
2 | '''This runs "ls -l" on a remote host using SSH. |
3 | At the prompts enter hostname, user, and password. |
4 | ''' |
5 | import pexpect |
6 | import getpass |
7 | |
8 | host = raw_input('Hostname: ') |
9 | user = raw_input('User: ') |
10 | password = getpass.getpass('Password: ') |
11 | |
12 | child = pexpect.spawn("ssh -l %s %s /bin/ls -l"%(user, host)) |
13 | |
14 | child.expect('password:') |
15 | child.sendline(password) |
16 | |
17 | child.expect(pexpect.EOF) |
18 | |
19 | print child.before |
20 |
Note: See TracBrowser
for help on using the repository browser.