<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364321#M346522</link>
    <description>&lt;!--!*#--&gt;&lt;BR /&gt;set +u&lt;BR /&gt;if [ "$1" = ""  ];&lt;BR /&gt;then&lt;BR /&gt;   SERVER=apple&lt;BR /&gt;else&lt;BR /&gt;   SERVER="$1"&lt;BR /&gt;fi&lt;BR /&gt;if [ "$2" = "" ];&lt;BR /&gt;then&lt;BR /&gt;   DIR=DR_dir&lt;BR /&gt;else&lt;BR /&gt;   DIR="$2"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 23 Feb 2009 15:34:06 GMT</pubDate>
    <dc:creator>Michael Mike Reaser</dc:creator>
    <dc:date>2009-02-23T15:34:06Z</dc:date>
    <item>
      <title>Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364319#M346520</link>
      <description>I need help in writing a script. Here is what I want to do.&lt;BR /&gt;&lt;BR /&gt;The script runs and passed two command line arguments to the script like:&lt;BR /&gt;&lt;BR /&gt;./script apple DR_dir&lt;BR /&gt;&lt;BR /&gt;Now in the script I want to check if $1 and $2 are passed as the command line arguments. If they are passed, I want to assign the value of $1 to CLIENT and $2 to DIR variable in the script otherwise default CLIENT to apple and DIR to DR_dir.&lt;BR /&gt;&lt;BR /&gt;if ($1 is set)&lt;BR /&gt;then &lt;BR /&gt;SERVER=$1&lt;BR /&gt;else&lt;BR /&gt;SERVER=apple&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;if ($2 is set)&lt;BR /&gt;then &lt;BR /&gt;DIR=$2&lt;BR /&gt;else&lt;BR /&gt;DR_dir=DR_dir&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;Can some one please help me in these if statements?</description>
      <pubDate>Mon, 23 Feb 2009 15:17:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364319#M346520</guid>
      <dc:creator>Waqar Razi</dc:creator>
      <dc:date>2009-02-23T15:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364320#M346521</link>
      <description>&lt;!--!*#--&gt;CLIENT=$1&lt;BR /&gt;[ -n $CLIENT ] || CLIENT="apple"&lt;BR /&gt;&lt;BR /&gt;DIR=$2&lt;BR /&gt;[ -n $DIR ] || DIR="DR_dir"&lt;BR /&gt;&lt;BR /&gt;This just tests if the condition is true, if it's false then execute whatever is behind ||.&lt;BR /&gt;&lt;BR /&gt;If $DIR contains anything this statement will return true and || is ignored.&lt;BR /&gt;&lt;BR /&gt;-n checks if the string length is non-zero. If it's non-zero, the statement returns true, otherwise false.&lt;BR /&gt;&lt;BR /&gt;Here's a url to a bunch of condition syntaxes.&lt;BR /&gt;&lt;A href="http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html#sect_07_01_01" target="_blank"&gt;http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html#sect_07_01_01&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Mon, 23 Feb 2009 15:33:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364320#M346521</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-02-23T15:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364321#M346522</link>
      <description>&lt;!--!*#--&gt;&lt;BR /&gt;set +u&lt;BR /&gt;if [ "$1" = ""  ];&lt;BR /&gt;then&lt;BR /&gt;   SERVER=apple&lt;BR /&gt;else&lt;BR /&gt;   SERVER="$1"&lt;BR /&gt;fi&lt;BR /&gt;if [ "$2" = "" ];&lt;BR /&gt;then&lt;BR /&gt;   DIR=DR_dir&lt;BR /&gt;else&lt;BR /&gt;   DIR="$2"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Feb 2009 15:34:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364321#M346522</guid>
      <dc:creator>Michael Mike Reaser</dc:creator>
      <dc:date>2009-02-23T15:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364322#M346523</link>
      <description>Hi Wagar:&lt;BR /&gt;&lt;BR /&gt;One way:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;if [ -z "$1" ]; then&lt;BR /&gt;    SERVER="apple"&lt;BR /&gt;else&lt;BR /&gt;    SERVER=$1&lt;BR /&gt;fi&lt;BR /&gt;if [ -z "$2" ]; then&lt;BR /&gt;    DIR="DR_dr"&lt;BR /&gt;else&lt;BR /&gt;    DIR=$2&lt;BR /&gt;fi&lt;BR /&gt;echo "CLIENT=${CLIENT}"&lt;BR /&gt;echo "DIR=${DIR}"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 23 Feb 2009 15:36:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364322#M346523</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-23T15:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364323#M346524</link>
      <description>I don't have an HP handy to test, but I think this "default value" syntax is in the current POSIX sh spec and has been in Korn for a while.&lt;BR /&gt;&lt;BR /&gt;CLIENT=${1:-apple}&lt;BR /&gt;DIR=${2:-DR_dir}</description>
      <pubDate>Mon, 23 Feb 2009 18:24:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364323#M346524</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2009-02-23T18:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364324#M346525</link>
      <description>Hey;&lt;BR /&gt;&lt;BR /&gt;The default syntax as presented above is definitely the way to go:&lt;BR /&gt;&lt;BR /&gt;$ cat testors&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;Client=${1:-apple}&lt;BR /&gt;Dir=${2:-DR_dir}&lt;BR /&gt;&lt;BR /&gt;printf "%-8s %s\n" ${Client} ${Dir}&lt;BR /&gt;$ ./testors&lt;BR /&gt;apple    DR_dir&lt;BR /&gt;$ ./testors pear&lt;BR /&gt;pear     DR_dir&lt;BR /&gt;$ ./testors pear cobbler&lt;BR /&gt;pear     cobbler&lt;BR /&gt;&lt;BR /&gt;HTH;&lt;BR /&gt;&lt;BR /&gt;Doug O'Leary</description>
      <pubDate>Mon, 23 Feb 2009 19:47:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364324#M346525</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2009-02-23T19:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364325#M346526</link>
      <description>&lt;!--!*#--&gt;&amp;gt;otherwise default CLIENT to apple and DIR to DR_dir.&lt;BR /&gt;&lt;BR /&gt;This could be as simple as counting parms:&lt;BR /&gt;if [ $# -ge 1 ]; then&lt;BR /&gt;   SERVER=$1&lt;BR /&gt;else&lt;BR /&gt;   SERVER=apple&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Doug: The default syntax as presented above is definitely the way to go:&lt;BR /&gt;&lt;BR /&gt;Right, Heironimus' solution will work even if -u is set.&lt;BR /&gt;And when using that ":", null parms will take the default:&lt;BR /&gt;$ ./testors "" ""&lt;BR /&gt;apple DR_dir</description>
      <pubDate>Mon, 23 Feb 2009 21:05:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4364325#M346526</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-23T21:05:14Z</dc:date>
    </item>
  </channel>
</rss>

