- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Expect script...
Operating System - HP-UX
1821051
Members
2465
Online
109631
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2004 05:15 AM
тАО10-07-2004 05:15 AM
Ok, so this is my first time using expect. I installed it and configured it fine and for the most part it's working, but I can't seem to execute any commands after I login (at least I don't think it's executing anything). I can log in fine, but it just logs out at the end, it's not showing me that it executed the "ls" command or "find" command. Any help please! This just smells of a bunny:) Here is my script:
------------
#!/usr/local/bin/expect -d
spawn /usr/local/bin/ssh root@
expect "root@'s password: "
send "\r"
expect "# "
send "find / -name TEMPFILE \r"
send "bye\r"
--------------
To execute I just run ./backups.sh
Thanks!
-Hazem
------------
#!/usr/local/bin/expect -d
spawn /usr/local/bin/ssh root@
expect "root@
send "
expect "# "
send "find / -name TEMPFILE \r"
send "bye\r"
--------------
To execute I just run ./backups.sh
Thanks!
-Hazem
Solved! Go to Solution.
- Tags:
- expect
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2004 05:29 AM
тАО10-07-2004 05:29 AM
Re: Expect script...
Try using the -f option as well, and then
embed the expect commands in a "here" file in the script:
#!/bin/ksh
/usr/local/bin/expect -d -f < set timeout -1
match_max 100000
spawn /usr/local/bin/ssh root@
expect "root@'s password: "
send "\r"
expect "# "
send "find / -name TEMPFILE \r"
send "bye\r"
EOF
Note the two lines I added as well.
mark
embed the expect commands in a "here" file in the script:
#!/bin/ksh
/usr/local/bin/expect -d -f <
match_max 100000
spawn /usr/local/bin/ssh root@
expect "root@
send "
expect "# "
send "find / -name TEMPFILE \r"
send "bye\r"
EOF
Note the two lines I added as well.
mark
the future will be a lot like now, only later
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2004 10:31 AM
тАО10-07-2004 10:31 AM
Solution
Hi Hazem,
There should be some expectation after you send 'find / -name" commmand. So, modify it as
expect "# "
send "find / -name TEMPFILE \r"
expect "# "
send "exit\r"
You can also do a
set pid [spawn /usr/local/bin/ssh root@]
After send 'exit\r', you can add 'exec kill $pid' just to make sure the telnet session gets killed.
-Sri
There should be some expectation after you send 'find / -name" commmand. So, modify it as
expect "# "
send "find / -name TEMPFILE \r"
expect "# "
send "exit\r"
You can also do a
set pid [spawn /usr/local/bin/ssh root@
After send 'exit\r', you can add 'exec kill $pid' just to make sure the telnet session gets killed.
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 07:43 AM
тАО10-08-2004 07:43 AM
Re: Expect script...
And the bunny goes to Sridhar!!!! That did it!!! Thank you!!! Thanks for your suggestions as well Mark!
-Hazem
-Hazem
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP