How to redirect standard input in a bash script?

How to redirect standard input in a bash script?

But that doesn’t work because when the variable $input is “&0”, bash interprets it as a filename. However, I could just do: The problem is that ./myScript is actually a long command line that I don’t want to duplicate, nor do I want to create a function for it because it’s not that long either (it’s not worth it).

What happens if the second redirection fails in Bash?

Note that the command shown will execute the second exec if either the condition is false or the first exec fails. If you don’t want a potential failure to do that then you should use an if / else: but then subsequent redirections from file descriptor 3 will fail if the first redirection failed (after the condition was true).

How to duplicate file descriptors in bash script stack?

First of all stdin is file descriptor 0 (zero) rather than 1 (which is stdout). You can duplicate file descriptors or use filenames conditionally like this:

Can You use’myscript’and’eval’in Bash?

If you’re careful, you can use ‘ eval ‘ and your first idea. However, you say that ‘myScript’ is actually a complex command invocation; if it involves arguments which might contain spaces, then you must be very careful before deciding to use ‘ eval ‘.

How does bash script for OpenVPN logon work?

So the script would populate and confirm the 2 authorization fields. Then once populated and confirmed, I will be connected to the VPN. I appreciate any help, and please let me know if more information is required.

How to run a shell script in Bash?

For the start, I tried implementing the solution proposed at https://stackoverflow.com/questions/21001220/bash-sequence-wait-for-output-then-start-next-program as a shell script I run this script as sh ssh-vpn.sh in the fish shell.

How to enable Auth user pass in OpenVPN?

Recompile OpenVPN with the ENABLE_PASSWORD_SAVE flag set ( configure –enable-password-save on UNIX), and then –auth-user-pass in your config file will accept a filename as an optional argument giving the location on disk where username and password are stored.