I am trying to programmatically call from my java program a shell script that in turn executes a command depending of the parameter sent.
the command to be executed inside the connectvpn.sh shell script is:
echo myrootpassword | sudo -S /usr/local/Cellar/openvpn/2.3.8/sbin/openvpn --config /usr/local/etc/openvpn/1.opvn
or
echo myrootpassword | sudo -S /usr/local/Cellar/openvpn/2.3.8/sbin/openvpn --config /usr/local/etc/openvpn/2.opvn
and so on from a long list, where the filename number I want to be variable depending on the value of the parameter received
So I want my java program to be able to use always the same shell script but use different .ovpn file depending on the parameter sent.
I believe that on my java program I have to call it something like this:
server_number = 1;
ProcessBuilder pb = new ProcessBuilder("./connectvpn.sh", server_number);
Process proc = pb.start();
What would go in the shell script so that the filename called is variable and for the example shown it uses 1 but other times it uses whatever number is sent as parameter?
Thank you very much!