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?
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
Get help from others!