Pass input from file to teminal

Forum rules
Before you post please read how to get help
Post Reply
GriffinD00r
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

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

gm10
Level 10
Level 10
Posts: 3486
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.

User avatar
jimallyn
Level 18
Level 18
Posts: 8455
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!
Image

“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: 417
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 us877.nordvpn.com.tcp.ovpn
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”