Web hosting support - warning: ‘-’ deprecated; use ‘ps auwx’, not ‘ps

warning: ‘-’ deprecated; use ‘ps auwx’, not ‘ps -auwx’ By using the getOSName function given earlier in this chapter, we can adapt the getPID function to work with both the BSD and System V versions of ps. The modified version of getPID is as follows: getPID() { if [ $# -lt 1 ] ; then echo “ERROR: Insufficient Arguments.” >&2 return 1 fi case getOSName in bsd|sunos|linux) PSOPTS=”-auwx” ;; *) PSOPTS=”-ef” ;; esac /bin/ps $PSOPTS 2> /dev/null | grep “$1″ | grep -v grep | awk ‘{ print $2; }’ } The two main changes are l A case statement sets the variable PSOPTS based on the operating system name. l The STDERR of ps is redirected to /dev/null in order to discard the warning message generated on newer versions of Linux. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 23: Scripting for Portability Previous Chapter Next Chapter Sections in this Chapter: Determining UNIX Versions Questions Techniques for Increasing Portability Terms Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Leave a Reply