I am extremely green and new to Linux, so apologies in advance if this is off topic, or I am using the wrong terminology, etc.
I am writing a shell script to be executed on Ubuntu/WSL through calling Powershell from a node.js project. I pass a string containing the
wsl command along with the path to the shell script I am trying to run to the PowerShell module like below
new PowerShell("wsl ./lpass.sh")
The shell script is able to run perfectly fine, however, I have a line of code that NEEDS to pass input to a command prompt when ran. This line of code sends a log-in request to a server which then responds, prompting the user for their password to be entered. I have been able to get this line of code working, passes the user input to the command when prompted, when I call the script with just this one line. This is what the
lpass.sh file looks like when I get the command working in the nature that I would like.
#!/bin/sh echo 'Password' | LPASS_DISABLE_PINENTRY=1 lpass login --force [email protected]
With the file configured this way, I am able to log-in to the LastPass account that I would like just by calling the script from the PowerShell command line. Using the piping, my password is passed and entered as input to the command prompt when elevated. However, obviously, I would like to do more than just log into the account through LastPass's CLI.
What I would like to be able to do is, log into the LastPass account, and then perform more actions through the LastPass CLI after I have logged in. I would like the
lpass.shfile to have more commands and code to it than just one line like so...
#!/bin/sh echo 'Test' | LPASS_DISABLE_PINENTRY=1 lpass login --force [email protected] lpass show -G -x --json poopy | jq '.' > poopy.json
The problem is if I run the file like shown above, the command prompt does not take my input before the pipe and thus does not log me into the LastPass account. The command after appears to be working fine, however I am not sure of the result as I am not able to perform that command without being logged into LastPass.
How can I write the shell script so that my first line
echo "password" | lpass login accepts the input before the pipe but also has more than one line of code within it as well? Is there somewhere or something that describes how command prompts interact with the rest of the script/ how shell scripts execute? I was able to find some documentation on shell scripts here and a few other places however I am struggling to find the exact problem that I am encountering. Or even better, what I am really interested in, which is how command prompts are being interacted with by the shell from a script and how the shell executes/runs/debugs the scripts that causes the command to not run properly with more lines of codes after it.