I have a shellscript
ABCD.sh and it will have a command to upload a file onto server which will prompt for username and password.
Instead of providing username and password there, I would like to pass the username and password as an external argument only, how it is possible?
username =$1 password=$2 pushcommand
pushcommand will ask to enter username and password; the shellscript should automatically take it from
If pushcommand simply reads first username and then password from standard input, separated by newline, you can do the following:
echo "$usernamen$password" | pushcommand
The "echo" call here will output the username and password variables on separate lines.
The "|" means "take the output of the command on the left, and feed it as input to the command on the right". This construct is called a "pipe" in shell scripts.
For scripting more complex interactions, I'd recommend looking at expect or possibly kermit. To get help with expect or kermit, you'd have to post an example on how an interactive use of pushcommand actually looks like, e.g. what prompts it displays and so on.
Answered by rosarote elfe on December 15, 2020
1 Asked on September 14, 2020 by young_souvlaki
2 Asked on September 14, 2020 by skg
5 Asked on September 13, 2020 by user394
1 Asked on September 10, 2020 by ansgar
1 Asked on September 7, 2020 by tsm
2 Asked on September 4, 2020 by fivedogit
0 Asked on September 3, 2020 by rohit-pillai
0 Asked on September 1, 2020 by hba
1 Asked on August 29, 2020 by paddy
0 Asked on August 28, 2020 by yeremia-danang
2 Asked on August 27, 2020 by roman
2 Asked on August 27, 2020 by indranil
1 Asked on August 24, 2020 by saurav-raj-joshi
2 Asked on August 20, 2020 by myndstream
0 Asked on August 18, 2020 by harriet
1 Asked on August 17, 2020 by fidodido
Get help from others!