Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE12
yast2-printer
test_remote_socket.without_ping
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File test_remote_socket.without_ping of Package yast2-printer
#! /bin/bash # # Test ability to connect to remote direct socket (JetDirect) server. # # Exits: 0 port on host accepts data # 1 host $1 not set # 2 no connection possible to port on host # 4 connection possible to port on host but does not accept data # The program head is in the coreutils RPM and therefore assumed to exist. # # Johannes Meixner <jsmeix@suse.de> 2002, 2007, 2008, 2009, 2010, 2011, 2014 # Jiri Srain <jsrain@suse.cz>, 2002 # $Id: test_remote_socket 43943 2008-01-28 13:38:58Z mzugec $ #set -x # Make sure to have a clean environment: export PATH="/sbin:/usr/sbin:/usr/bin:/bin" export LC_ALL="POSIX" export LANG="POSIX" umask 022 # Disable bash file name globbing: set -f MY_NAME=${0##*/} HOST="$1" [ -z "$HOST" ] && { echo -en "\nUsage:\n$MY_NAME HOST [PORT]\n" 1>&2 ; exit 1 ; } PORT="$2" [ -z "$PORT" ] && PORT=9100 # Test whether connection is possible to port on host: # If the test fails, show an error message and exit with non-zero exit code. # The outermost subshell avoids job control messages like "[1] job_pid" and "[1]+ Done..." or "[1]+ Terminated...". # The hardcoded 2 seconds timeout is waited in any case so that the test needs always basically that timeout time. # In POSIX shells wait returns the exit code of the job even if it had already terminated when wait was started, # see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wait.html that reads: # "This volume of POSIX.1-2008 requires the implementation to keep the status # of terminated jobs available until the status is requested": if ( ( echo -n '' >/dev/tcp/$HOST/$PORT ) & ECHO_PID=$! ; sleep 2s ; kill $ECHO_PID &>/dev/null ; wait $ECHO_PID ) then # Test whether port on host accepts data: if ( ( echo -en '\r' >/dev/tcp/$HOST/$PORT ) & ECHO_PID=$! ; sleep 2s ; kill $ECHO_PID &>/dev/null ; wait $ECHO_PID ) then echo -en "\nPort '$PORT' on host '$HOST' accepts data\n" exit 0 fi echo -en "\nConnection possible to port '$PORT' on host '$HOST' but does not accept data\n" exit 4 fi # The test failed: echo -en "\nNo connection possible to port '$PORT' on host '$HOST'." echo -en "\n(Network issue or wrong host or wrong port or firewall active there?)\n\n" exit 2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor