LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash: open url command (and ignore error) (https://www.linuxquestions.org/questions/linux-general-1/bash-open-url-command-and-ignore-error-934547/)

Milchknilch 03-15-2012 02:36 AM

bash: open url command (and ignore error)
 
Hi,

I'm running a bash script via Jenkins CI and want to open an url
http://server.whats.itl:4444/seleniu...SeleniumServer
to shut down selenium server.

My first intention was to use "wget --remove-after" with > /dev/null 2>&1, but in case the server is not running, the build fails.

I hope someone could tell me a more suitable command than wget (this can't be so hard, but it seems like I'm searching for the wrong terms) and then maybe I can figure out a way how to deal with the error.

EricTRA 03-15-2012 02:41 AM

Hi,

If your wget command works when the server is running, then you could include it in an if condition to check first if the server is available, for example checking the ip : port combination. If the server is up, it would be shut down by the command and if it's not up then the build would continue.

Kind regards,

Eric

Milchknilch 03-15-2012 04:55 AM

Thank you for your suggestion, but I think I now found a solution that is a little bit less complicated than checking availability first:

curl -f --connect-timeout 3 http://dingenskirchen.org:4444/selen...SeleniumServer || :

Even with "-f" option I got some output from curl and to prevent the Jenkins script fail on errors I used the "|| :"

EricTRA 03-15-2012 04:56 AM

Hi,

Nice catch! If you consider your problem solved, then please mark the thread as such.

Kind regards,

Eric


All times are GMT -5. The time now is 12:34 AM.