Reputation: 149
I'd like to write a bash script which automates a specific process.
It starts an analyzing cms-tool with passing an identifier.
After passing an identifier that tool is asking for user password.
The script should read through a list of such identifiers and input the user password after each forwarded identifier.
The following simple example shows the process with an identifier called 'eventDatePicker' :
jmm@workstation:/opt/media/tools/bin$ ./cm old-viewtypes-usage -u admin -s "/test/" -t "/home/media/transfer" -vt eventDatePicker
password:
This is my created bash script so far but I don't know how to implement a function for passing a user password:
#!/bin/bash
# list with identifiers
input="/opt/media/tools/bin/technical_identifier"
#path to analyzing tool
cd /opt/media/tools/bin || exit
while IFS= read -r line
do
./cm old-viewtypes-usage -u admin -s "/test/" -t "/home/media/transfer" -vt "$line"
# command for passing the user password
done < "$input"
I tried it out by using read
or expect
but it didn't work out.
I'd be glad for any help.
Upvotes: 2
Views: 955
Reputation: 1475
You might like to learn the 'expect' dialect of Tcl. Start with running 'autoexpect' and then change the output script to take parameters and send your password.
This is really the only sane way of scripting up interactive scripts.
Upvotes: 1