![]() |
|
[Help] [SOLVED] I need help with a simple bash script - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5) +---- Thread: [Help] [SOLVED] I need help with a simple bash script (/showthread.php?tid=5816402) |
[SOLVED] I need help with a simple bash script - antmatt - Mar 26, 2018 Im tired of the effort it takes to script new clients for my vpn server, and since my ip changes weekly and i have a lot of people to make clients for, i need an easier way to do this. Essentially i need my script to accept an input, so like “./myscript XXX” and have it do the following things $ cd openvpn-ca/ $ source vars $ ./build-key XXX $ cd ~client-configs/ $ ./makeconfig.sh XXX $ cd files/ $ sudo cp XXX /home/ftpserver/ftp/files/ (That last location is where i pull the client files from on my phone so i can send them to people by email and such) It should be simple but im new to scripting so i dont know how to go about this... i can do the echo “mypassword” | sudo -S cp Too to make it easier but whatever works. Thanks for reading if you did lol ___________________________________________________________ update since none of you helped ya boy out this is what I did and it worked and i couldnt find any tutorials on google for what I needed specifically I just got lucky with some educated guesses but here it is Code #!/bin/bashthe echo mypassword | sudo -S line lets you run commands that require sudo privileges without having to enter your password, since it echos your password for you. this is unsecure and a bad idea since it stores your password in plain text in the script, but if you leave your computer locked and secure and such then you will be fine. the average user wont know what theyre looking for and as long as nobody hacks you then there is no worries. I know im secure on my network and computer end so its safe for me to do that, but keep the risk in mind. |