cancel
Showing results for 
Search instead for 
Did you mean: 

Help creating expect script for manifest upload

eric_iannone_77
New Contributor II
Looking to create a command script in HPNA to automate manifest upload via tftp server to multiple devices.

I found an expect script on HPNA (below) which i modified a bit (ip, manifest file name) but executing it results in it hanging on the "Please type 'yes' or 'no':" prompt after the copy tftp command. 

Appreciate any feedback on how to correct this please. 

again, this is not my work, just trying to understand how it's working to fine tune it for this purpose.

https://github.com/Lynkdev/Expect-learning/tree/master/Ruckus




4 REPLIES 4

hyosang_choi
Valued Contributor
I'm not shell script expert, but I think the main reason below is blank.


send "copy tftp system-manifest *.*.*.* FI08070e_Manifest.txt all-images-secondary\r"
set more true
expect {
     -ex "$more_prompt" {
                   send " " exp_continue
      } $config_prompt {
      } $prompt {
      }
}


$config_prompt {
      } $prompt { 
      }

That means if you met $config_prompt, then do nothing({}), and if you met $prompt, then also do nothing({}).

Try to modify and test.

Try to modify like below.

expect { 
     -ex "y*n" { 
                   send "y/r"
      exp_continue 
      } $config_prompt {
      } $prompt { 
      }
}

That means if you met 'yes or no' then type y and enter.

And retrun to expect top(the expect {}).

In breief, the expect loop is used at mutiple condition.

1) yes or no is y enter

2) if you met 1), retrun to first again, 

3) If you don;t met 1), proceed next condition ; $config_prompt {} -> $prompt {}.

And next continously....

Thanks for the reply. This does make sense and I tried running with below changes: 

I removed $config_prompt as this is being run through enable mode, it's set as unknown anyways. Is this correct?

send "copy tftp system-manifest *.*.*.* FI08070e_Manifest.txt all-images-secondary\r"
set more true
expect {
 -ex "y*n" {
 send "y\r"
 exp_continue
 } $prompt {
 }
}

Posted full results from the output below. I also noticed that after running this command script, it takes about two minutes just to show the send "copy tftp" command in the log output as it's running.

https://github.com/Lynkdev/Expect-learning/blob/master/Ruckus/Results%20from%20Expect%20script


Not sure what the # check for previous logout portion of the script is doing towards the bottom, is this needed?



eric_iannone_77
New Contributor II
Thanks for the reply. This does make sense and I tried running with below changes: 

I removed $config_prompt as this is being run through enable mode, it's set as unknown anyways. Is this correct?

send "copy tftp system-manifest *.*.*.* FI08070e_Manifest.txt all-images-secondary\r"
set more true
expect { 
 -ex "y*n" { 
 send "y\r" 
 exp_continue 
 } $prompt { 
 }
}

Posted full results from the output below. I also noticed that after running this command script, it takes about two minutes just to show the send "copy tftp" command in the log output as it's running.

https://github.com/Lynkdev/Expect-learning/blob/master/Ruckus/Results%20from%20Expect%20script


Not sure what the # check for previous logout portion of the script is doing towards the bottom, is this needed?