- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- How to run multiple commands using expect?
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
06-06-2012 10:02 AM
06-06-2012 10:02 AM
How to run multiple commands using expect?
Hi Gurus,
I am in process of creating a script to get multiple commands o/p from some set of servers and collecting its output in a single file.
My below commands works fine..
/usr/bin/expect -c "spawn ssh uname@hostname "'head /etc/hosts'" ; expect "'password:'" ; send "usr-passwd" ; interact "
but not this one..
/usr/bin/expect -c "spawn ssh uname@hostname "'head /etc/hosts; uname -a'" ; expect "'password:'" ; send "usr-passwd" ; interact "
this is because expect splits commands due to semicolon added between them. Is there any escape character which can be used here to fix this??
Regards,
Murugan
- Tags:
- expect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-07-2012 08:49 AM
06-07-2012 08:49 AM
Re: How to run multiple commands using expect?
>a script to get multiple commands output
Any reason you don't create a script that does the multiple commands and then run expect on that script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-07-2012 10:20 PM
06-07-2012 10:20 PM
Re: How to run multiple commands using expect?
Hello Dennis Handly,
Thank you, for your response.
My goal is to get multiple commands output using a single/simple script from different servers. Also, I would like to give the username and password in the same script itself. Password less login using ssh-key or other solutuions doesn't satisfy my requirement.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP