The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 11-04-2008
igorc igorc is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 7
Quote:
Originally Posted by muhilan.r View Post
Hi,
I have been asked to automate the package installation through shell script.
I have 10 packages to be installed and in that 4 packages requires additional DB information(Host Name, Credentials etc) to be passed and for remaining 6 packages i need to provide the "Yes" - "No" .
I have tried with expect , admin file but as per my understanding both requires standard input/steps to defined. Can i use expect with If loop after spawning the command
say f or ex : Spawn pkgadd "Test.pkg"
if (expect [Host Name])
then
send "HOST NAME"
Is it possible to validate the outcome of the command and input the option through shell script? Please Clarify. or Do we have any other approach to perform this?

Thanks,
Muhil

Have a look at this code snippet from one of my scripts doing automating SFTP:

/usr/bin/expect <<EOF
spawn /usr/bin/sftp USERNAME@SERVER_IP
expect {
"Password: " {
send "PASSWORD\r"
}
"Are you sure you want to continue connecting (yes/no)? " {
send "yes\n"
expect "Password: "
send "PASSWORD\r"
}
}
expect "sftp> "
send "cd $IMEIS \r"
expect "sftp> "
send "lcd $LOCALDIR \r"
expect "sftp> "
send "get $file \r"
expect "sftp> "
send "bye \r"
EOF


You should be able to change it to your like.