HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Expect Script Help
Operating System - HP-UX
1825799
Members
2247
Online
109687
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
Forums
Discussions
Discussions
Discussions
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
06-26-2009 09:25 AM
06-26-2009 09:25 AM
Expect Script Help
I have a ksh script which I have written but needs to change it to expect script so that I can automate it but dont know much about expect and while I tried its not working
can anyone help me on this plz, how can i conver that into expect script
here is my script which basically checks first and copy and untar the installation files and install fixpack which is just for one server and i have to copy it to all the servers to do it and while doing it ask for password as ssh is not setup for the accounts im using and I am told its not supposed to be setup for this account so that there is no way i can set up ssh for this account.
My script runs fine and install fixpack in one server provided i enter the password manually when it prompt for.
But I am trying to do something like expect script which can scp this script to all the boxes and can install the fixpack without prompting me for password or any other way does the job i mentioned.
I have done simple expect script only and couldnt figure out how to do for this one.
Could anybody help me plz. I will appreciate any help.
--------script-----
------------------
#!/usr/bin/ksh
#set -xv
checking () {
##current_fp_version = $(/usr/local/TWS/TWSPRD84/version/version|grep FP0003)
echo "Checking The Fix Pack Version, If Alrady Installed.........."
echo "-------------------------------------------------------------"
if [[ $(/usr/local/TWS/TWSPRD84/version/version|grep FP0003) = 0 ]]; then
echo "Already have FixPack3 Installed"
exit
else
echo "Doesnt Have New Version Of FixPack, Have to install FP-3, Starting the Installation............."
fi
}
checking
copy_and_tar() {
server=$(hostname)
echo "Installing fix pack in $server"
###Making FixPack Directory First
mkdir /usr/local/TWS/TWSPRD84/FIXPACK3
chmod 755 /usr/local/TWS/TWSPRD84/FIXPACK3
cd /usr/local/TWS/TWSPRD84/FIXPACK3
echo "Copying Fix Pack Tar File From Source, It May Take A While, Please Wait..." | tee fix_pack_installation_log
scp bowie:/usr/local/TWS/TWSPRD84/DOWNLOADS/FIXPACK3/HP_TWS_FP0003.tar .
original_size = "ssh bowie ls -al /usr/local/TWS/TWSPRD84/DOWNLOADS/FIXPACK3/HP_TWS_FP0003.tar|awk '{print $5}'"
echo $original_size
new_size= "ls -al /usr/local/TWS/TWSPRD84/FIXPACK3/HP_TWS_FP0003.tar|awk '{print $5}'"
echo $new_size
echo "Checking File Size"
if [ $original_size = $new_size ]; then
echo "File Size Is Same In Source And Destination"
else
echo "Have to copy the tar file again, size varies in source and destination"
exit
fi
echo "Now Untaring The Files......Wait For It To Get Completed"
cd /usr/local/TWS/TWSPRD84/FIXPACK3
tar -xvf HP_TWS_FP0003.tar
}
copy_and_tar | tee fix_pack_copy&tar_log
installing_fix_pack () {
##Renaming Directories so that we can install as ROOT
mv /usr/local/TWS/TWSPRD84/DOWNLOADS /usr/local/TWS/TWSPRD84/DOWNLOADS_OLD
mv /usr/local/TWS/TWSPRD84/FIXPACK3 /usr/local/TWS/TWSPRD84/DOWNLOADS
cd /usr/local/TWS/TWSPRD84/DOWNLOADS/HPUX
mv SETUP.bin SETUP.bin_rename_later
cp twspatch SETUP.bin
##needs to shut down the TWS before installing
/usr/local/TWS/TWSPRD84/bin/conman "shut;wait"
sudo /usr/local/TWS/TWSPRD84/DOWNLOADS/HPUX/SETUP.bin -install -uname twsprd84
##starting the TWS again after everything is done
/usr/local/TWS/TWSPRD84/bin/conman "start"
cd /usr/local/TWS/TWSPRD84/DOWNLOADS/HPUX
mv SETUP.bin_rename_later SETUP.bin
##Renaming Directories Back To Original Names
cd /usr/local/TWS/TWSPRD84/
mv /usr/local/TWS/TWSPRD84/DOWNLOADS /usr/local/TWS/TWSPRD84/FIXPACK3
mv /usr/local/TWS/TWSPRD84/DOWNLOADS_OLD /usr/local/TWS/TWSPRD84/DOWNLOADS
mv /usr/local/TWS/TWSPRD84/FIXPACK3 /usr/local/TWS/TWSPRD84/DOWNLOADS/FIXPACK3
}
installing_fix_pack | tee fix_pack_installation_log
Thank You
can anyone help me on this plz, how can i conver that into expect script
here is my script which basically checks first and copy and untar the installation files and install fixpack which is just for one server and i have to copy it to all the servers to do it and while doing it ask for password as ssh is not setup for the accounts im using and I am told its not supposed to be setup for this account so that there is no way i can set up ssh for this account.
My script runs fine and install fixpack in one server provided i enter the password manually when it prompt for.
But I am trying to do something like expect script which can scp this script to all the boxes and can install the fixpack without prompting me for password or any other way does the job i mentioned.
I have done simple expect script only and couldnt figure out how to do for this one.
Could anybody help me plz. I will appreciate any help.
--------script-----
------------------
#!/usr/bin/ksh
#set -xv
checking () {
##current_fp_version = $(/usr/local/TWS/TWSPRD84/version/version|grep FP0003)
echo "Checking The Fix Pack Version, If Alrady Installed.........."
echo "-------------------------------------------------------------"
if [[ $(/usr/local/TWS/TWSPRD84/version/version|grep FP0003) = 0 ]]; then
echo "Already have FixPack3 Installed"
exit
else
echo "Doesnt Have New Version Of FixPack, Have to install FP-3, Starting the Installation............."
fi
}
checking
copy_and_tar() {
server=$(hostname)
echo "Installing fix pack in $server"
###Making FixPack Directory First
mkdir /usr/local/TWS/TWSPRD84/FIXPACK3
chmod 755 /usr/local/TWS/TWSPRD84/FIXPACK3
cd /usr/local/TWS/TWSPRD84/FIXPACK3
echo "Copying Fix Pack Tar File From Source, It May Take A While, Please Wait..." | tee fix_pack_installation_log
scp bowie:/usr/local/TWS/TWSPRD84/DOWNLOADS/FIXPACK3/HP_TWS_FP0003.tar .
original_size = "ssh bowie ls -al /usr/local/TWS/TWSPRD84/DOWNLOADS/FIXPACK3/HP_TWS_FP0003.tar|awk '{print $5}'"
echo $original_size
new_size= "ls -al /usr/local/TWS/TWSPRD84/FIXPACK3/HP_TWS_FP0003.tar|awk '{print $5}'"
echo $new_size
echo "Checking File Size"
if [ $original_size = $new_size ]; then
echo "File Size Is Same In Source And Destination"
else
echo "Have to copy the tar file again, size varies in source and destination"
exit
fi
echo "Now Untaring The Files......Wait For It To Get Completed"
cd /usr/local/TWS/TWSPRD84/FIXPACK3
tar -xvf HP_TWS_FP0003.tar
}
copy_and_tar | tee fix_pack_copy&tar_log
installing_fix_pack () {
##Renaming Directories so that we can install as ROOT
mv /usr/local/TWS/TWSPRD84/DOWNLOADS /usr/local/TWS/TWSPRD84/DOWNLOADS_OLD
mv /usr/local/TWS/TWSPRD84/FIXPACK3 /usr/local/TWS/TWSPRD84/DOWNLOADS
cd /usr/local/TWS/TWSPRD84/DOWNLOADS/HPUX
mv SETUP.bin SETUP.bin_rename_later
cp twspatch SETUP.bin
##needs to shut down the TWS before installing
/usr/local/TWS/TWSPRD84/bin/conman "shut;wait"
sudo /usr/local/TWS/TWSPRD84/DOWNLOADS/HPUX/SETUP.bin -install -uname twsprd84
##starting the TWS again after everything is done
/usr/local/TWS/TWSPRD84/bin/conman "start"
cd /usr/local/TWS/TWSPRD84/DOWNLOADS/HPUX
mv SETUP.bin_rename_later SETUP.bin
##Renaming Directories Back To Original Names
cd /usr/local/TWS/TWSPRD84/
mv /usr/local/TWS/TWSPRD84/DOWNLOADS /usr/local/TWS/TWSPRD84/FIXPACK3
mv /usr/local/TWS/TWSPRD84/DOWNLOADS_OLD /usr/local/TWS/TWSPRD84/DOWNLOADS
mv /usr/local/TWS/TWSPRD84/FIXPACK3 /usr/local/TWS/TWSPRD84/DOWNLOADS/FIXPACK3
}
installing_fix_pack | tee fix_pack_installation_log
Thank You
- Tags:
- expect
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2009 09:57 AM
06-26-2009 09:57 AM
Re: Expect Script Help
I'd seriously consider exchanging keys so ssh / scp can work without the password.
if not, then something similar to the following might work:
#!/usr/local/bin/expect --
spawn
expect "Password:"
send "password\r"
send "\r"
============
fix "Password:" to match the prompt you get. substitute real password for "password\r"
this can be further scripted to run thru the above (once fixed / working) with servername / password pairs.
my choice would be passwordless ssh however, as its more secure, and once setup, its dead easy to use.
if not, then something similar to the following might work:
#!/usr/local/bin/expect --
spawn
expect "Password:"
send "password\r"
send "\r"
============
fix "Password:" to match the prompt you get. substitute real password for "password\r"
this can be further scripted to run thru the above (once fixed / working) with servername / password pairs.
my choice would be passwordless ssh however, as its more secure, and once setup, its dead easy to use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2009 08:38 AM
06-27-2009 08:38 AM
Re: Expect Script Help
As far as I see your necessity, You would better use TCL language, it seems very good especially in use this type of script, both condition check and automated telnet remote machine.. you can also use expect inside in TCL since they are compatible to work together.
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
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP