How to continue bash script execution after openvpn is launched?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












so I have this bash script right here. Basically, it connects my machine to a server and download files from the server and store them in the /tmp directory. The problem is that the bash script stops at the openvpn command and doesn't read what's next, even if the openvpn is in background. Any help please?



Sites=`ls`

for site in $Sites
do
((i=0))

cd $site/vpn

address="$(grep "172" info-$site.txt | cut -c 5-17)"
echo "IP: $address"

ret="$(route | grep "172.16" | cut -c 1-10)"


echo 'password_1' | sudo -S openvpn --config $site.ovpn --auth-user-pass $1$2/$site/vpn/login-$site.txt &

while [ X"$ret" = X"" -o "$i" -le 10 ]; do

echo "toto while"
ret="$(route | grep "172.16" | cut -c 1-10)"
sleep 1
let "i=i+1"
done

sshpass -p 'password2' scp root@"$address":/usr/envitech/DataReports/* /tmp;
done


But I get this error:



ssh connect to host xxxxxx port 22: Connection timed out






share|improve this question






















  • Did you try to do this manually on the xxxxxxx server?
    – Tomasz
    Mar 15 at 20:23














up vote
0
down vote

favorite












so I have this bash script right here. Basically, it connects my machine to a server and download files from the server and store them in the /tmp directory. The problem is that the bash script stops at the openvpn command and doesn't read what's next, even if the openvpn is in background. Any help please?



Sites=`ls`

for site in $Sites
do
((i=0))

cd $site/vpn

address="$(grep "172" info-$site.txt | cut -c 5-17)"
echo "IP: $address"

ret="$(route | grep "172.16" | cut -c 1-10)"


echo 'password_1' | sudo -S openvpn --config $site.ovpn --auth-user-pass $1$2/$site/vpn/login-$site.txt &

while [ X"$ret" = X"" -o "$i" -le 10 ]; do

echo "toto while"
ret="$(route | grep "172.16" | cut -c 1-10)"
sleep 1
let "i=i+1"
done

sshpass -p 'password2' scp root@"$address":/usr/envitech/DataReports/* /tmp;
done


But I get this error:



ssh connect to host xxxxxx port 22: Connection timed out






share|improve this question






















  • Did you try to do this manually on the xxxxxxx server?
    – Tomasz
    Mar 15 at 20:23












up vote
0
down vote

favorite









up vote
0
down vote

favorite











so I have this bash script right here. Basically, it connects my machine to a server and download files from the server and store them in the /tmp directory. The problem is that the bash script stops at the openvpn command and doesn't read what's next, even if the openvpn is in background. Any help please?



Sites=`ls`

for site in $Sites
do
((i=0))

cd $site/vpn

address="$(grep "172" info-$site.txt | cut -c 5-17)"
echo "IP: $address"

ret="$(route | grep "172.16" | cut -c 1-10)"


echo 'password_1' | sudo -S openvpn --config $site.ovpn --auth-user-pass $1$2/$site/vpn/login-$site.txt &

while [ X"$ret" = X"" -o "$i" -le 10 ]; do

echo "toto while"
ret="$(route | grep "172.16" | cut -c 1-10)"
sleep 1
let "i=i+1"
done

sshpass -p 'password2' scp root@"$address":/usr/envitech/DataReports/* /tmp;
done


But I get this error:



ssh connect to host xxxxxx port 22: Connection timed out






share|improve this question














so I have this bash script right here. Basically, it connects my machine to a server and download files from the server and store them in the /tmp directory. The problem is that the bash script stops at the openvpn command and doesn't read what's next, even if the openvpn is in background. Any help please?



Sites=`ls`

for site in $Sites
do
((i=0))

cd $site/vpn

address="$(grep "172" info-$site.txt | cut -c 5-17)"
echo "IP: $address"

ret="$(route | grep "172.16" | cut -c 1-10)"


echo 'password_1' | sudo -S openvpn --config $site.ovpn --auth-user-pass $1$2/$site/vpn/login-$site.txt &

while [ X"$ret" = X"" -o "$i" -le 10 ]; do

echo "toto while"
ret="$(route | grep "172.16" | cut -c 1-10)"
sleep 1
let "i=i+1"
done

sshpass -p 'password2' scp root@"$address":/usr/envitech/DataReports/* /tmp;
done


But I get this error:



ssh connect to host xxxxxx port 22: Connection timed out








share|improve this question













share|improve this question




share|improve this question








edited Mar 15 at 20:22









Tomasz

8,04052560




8,04052560










asked Mar 15 at 17:53









Manel O.

1




1











  • Did you try to do this manually on the xxxxxxx server?
    – Tomasz
    Mar 15 at 20:23
















  • Did you try to do this manually on the xxxxxxx server?
    – Tomasz
    Mar 15 at 20:23















Did you try to do this manually on the xxxxxxx server?
– Tomasz
Mar 15 at 20:23




Did you try to do this manually on the xxxxxxx server?
– Tomasz
Mar 15 at 20:23















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430450%2fhow-to-continue-bash-script-execution-after-openvpn-is-launched%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430450%2fhow-to-continue-bash-script-execution-after-openvpn-is-launched%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?