Pass input from file to teminal

Forum rules
Before you post please read how to get help
Post Reply
Level 1
Level 1
Posts: 1
Joined: Sat Jul 14, 2018 10:04 am

Pass input from file to teminal

Post by GriffinD00r » Sat Jul 14, 2018 10:25 am


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

Thanks in advance

Level 18
Level 18
Posts: 8261
Joined: Thu Jun 21, 2018 5:11 pm

Re: Pass input from file to teminal

Post by gm10 » Sat Jul 14, 2018 10:45 am

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.
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

User avatar
Level 18
Level 18
Posts: 8941
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Pass input from file to teminal

Post by jimallyn » Sat Jul 14, 2018 6:55 pm

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

Level 4
Level 4
Posts: 431
Joined: Fri Sep 23, 2016 10:19 am

Re: Pass input from file to teminal

Post by FreedomTruth » Fri Aug 03, 2018 8:12 pm

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
sudo requires -S to read password from stdin.
If you abide in My word, you are My disciples indeed. And you shall know the truth, and the truth shall make you free... Most assuredly, I say to you, whoever commits sin is a slave of sin... Therefore if the Son makes you free, you shall be free indeed.

Post Reply

Return to “Scripts & Bash”