convenience keys l:clear m:mark q:quit
[myplc.git] / plc.d / functions
index 987a99d..e2e128c 100644 (file)
@@ -1,12 +1,12 @@
 # -*-Shell-script-*-
+# $Id$
+# $URL$
 #
 # Common functions for PLC startup/shutdown scripts
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 export PATH=/sbin:/bin:/usr/bin:/usr/sbin
 
@@ -78,7 +78,7 @@ plc_daemon ()
 # Print IP address of hostname if resolvable
 gethostbyname ()
 {
-    perl -MSocket -e '($a,$b,$c,$d,@addrs) = gethostbyname($ARGV[0]); print inet_ntoa($addrs[0]) . "\n";' $1 2>/dev/null
+    python -c 'import socket; import sys; print socket.gethostbyname(sys.argv[1])' $1 2>/dev/null
 }
 
 # Forcefully make a symlink
@@ -111,5 +111,5 @@ upper ()
 
 # Make copies of stdout and stderr. The plc initscript redirects
 # stdout and stderr to a logfile if -v is not specified.
-[ ! -e /dev/fd/3 ] && exec 3>&1
-[ ! -e /dev/fd/4 ] && exec 4>&2
+[ ! -e /proc/self/fd/3 ] && exec 3>&1
+[ ! -e /proc/self/fd/4 ] && exec 4>&2