#!/bin/bash -xe cat << "JAVA" > Checker.java && javac Checker.java import java.net.HttpURLConnection; import java.net.URL; public class Checker { public static void main(String[] args) throws Exception { HttpURLConnection conn = (HttpURLConnection) new URL(args[0]) .openConnection(); System.exit( 200 == conn.getResponseCode() ? 0 : 1 ); } } JAVA java Checker http://google.pl && echo OK || echo BAD