Open francescobianco opened 3 years ago
I did some tests but without success
The base ideas was:
cat "$1" |
for loop to script file lines (the main while loop)eval
with explicit redirected input (but it works for BASH not for SH)I think in other way is impossible show user input in screen play.
@ko1nksm any luck about this?
Sorry for the late reply. This project is currently low priority for me and is not actively maintained. Therefore, I am replying with fragmentary information without sufficient confirmation.
The idea is to introduce a directive to pass input, if called command ask for human inputs
I don't think it's a bad idea, but there may be another way. For example, could the following code be used as a workaround?
#!/bin/sh
vtiger init < ./input.txt
yes | vtiger destroy
Use eval with explicit redirected input (but it works for BASH not for SH)
I would like to support POSIX shells as well as bash only whenever possible. However, this is not a requirement. I wrote the following script. And it worked. This means it may be able to support POSIX shells.
#!/bin/sh
echo "/var/www/html" > ./input.txt
echo "secret" >> ./input.txt
echo "MyPersonal CRM" >> ./input.txt
exec <./input.txt
echo "Where is your CRM?"
read line
echo "> $line"
echo "What your password?"
read line
echo "> $line"
echo "Give a name to this CRM?"
read line
echo "> $line"
In this way when command ask for multiple question it play with delay on each differt input and not all at the same time
Named pipes can be used to delay the input.
#!/bin/sh
mkfifo ./input.txt
( for i in $(seq 5); do sleep 1; echo $i; done > ./input.txt ) &
while IFS= read -r line; do
echo "$line"
done < ./input.txt
rm ./input.txt
Switch to cat "$1" | for loop to script file lines (the main while loop)
Perhaps it would be better to use < "$1"
instead of cat
. See Useless use of cat (UUOC).
When running with asciicinema, you may encounter unexpected problems. This is because asciicinema is capturing STDIN/STDOUT, and I have experienced this once.
I'm not familiar with vtiger, but passwords are sensitive information and may be read from the TTY instead of STDIN. In that case, it will be difficult to handle. Using expect
or stty
may solve that problem.
I built this project without fully designing it, and I feel it needs to be redesigned. However, Currently, I don't have enough time, so I can't start working right away.
I want record into asciicinema a script with user inputs something like this
The idea is to introduce a directive to pass input, if called command ask for human inputs
Actually I have a command line program that ask for three question like this:
My idea is create a file with the following instructions