Pass input from file to teminal

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
GriffinD00r

Pass input from file to teminal

Post by GriffinD00r »

Hi,

I'm new to Linux and Bash. I'm trying to automate VPN connection. I have started a .sh file to get rolling but I'm not sure how to pass my credentials from the executable into the Terminal. The script starts fine and the terminal window opens asking for my sudo password. I haven't been successful at figuring out how to pass the info from the file. Is it possible?

What I've got so far:

cd /etc/openvpn/ovpn_tcp
sudo openvpn us877.nordvpn.com.tcp.ovpn

Thanks in advance
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gm10

Re: Pass input from file to teminal

Post by gm10 »

Rather than answering that let me ask: Are you aware that you can create a VPN connection via the NetworkManager? If you need OpenVPN specifically, there's a plugin for it available in the Software Manager.
User avatar
jimallyn
Level 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Pass input from file to teminal

Post by jimallyn »

You probably don't need to do that, but if you do, I searched with Startpage for 'bash read from file' and got a lot of good returns. Some of them even I could understand!
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
FreedomTruth
Level 4
Level 4
Posts: 443
Joined: Fri Sep 23, 2016 10:19 am

Re: Pass input from file to teminal

Post by FreedomTruth »

I don't recommend storing your password in a file, but if that's what you really want to do:

Code: Select all

cat .passwordfile | sudo -S openvpn us877.nordvpn.com.tcp.ovpn
sudo requires -S to read password from stdin.
Locked

Return to “Scripts & Bash”