<?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 needed with case and if statements in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447224#M682893</link>
    <description>&lt;!--!*#--&gt;Hi Robert:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Can someone please help me understand the following: if [ "X$1" != "X" ]&lt;BR /&gt;&lt;BR /&gt;The script is (as you said) testing to see if '$1' (the first argument passed to it on the command line) exists or not.  I would have used the second technique in the snippet below:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;if [ "X$1" != "X" ]; then&lt;BR /&gt;    echo has_value&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ ! -z "$1" ]; then&lt;BR /&gt;    echo has_value&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;As for the two case statements with only one 'esac' for closure, that's a syntax error.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 25 Jun 2009 14:00:35 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-06-25T14:00:35Z</dc:date>
    <item>
      <title>Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447223#M682892</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have the following code that uses sftp to upload files and download files from a server.&lt;BR /&gt;server=pandora.test&lt;BR /&gt;port=\#2202&lt;BR /&gt;port=\#22&lt;BR /&gt;user="test"&lt;BR /&gt;pword="password"&lt;BR /&gt;action="initial"&lt;BR /&gt;put_dir="/Usr/test"               &lt;BR /&gt;get_dir="."                         &lt;BR /&gt;upload_dir="/home/pmp/topmp"&lt;BR /&gt;download_dir="/home/pmp/frompmp"&lt;BR /&gt;log_name="messages"&lt;BR /&gt;day=$(date +%d)&lt;BR /&gt;print_date=$(date '+%m-%d-%y %H:%M')&lt;BR /&gt;mail_to=xxxx@gmail.com&lt;BR /&gt; &lt;BR /&gt;if [ "X$1" != "X" ]                             &lt;BR /&gt;then&lt;BR /&gt;    print " "&lt;BR /&gt;    print "invocation date:  $print_date"&lt;BR /&gt;    print " "&lt;BR /&gt;fi&lt;BR /&gt;case $1 in&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;-u)&lt;BR /&gt; &lt;BR /&gt;  # different file formats for different dates&lt;BR /&gt; &lt;BR /&gt;  case $day in&lt;BR /&gt;    03 | 04 | 05 | 06)&lt;BR /&gt;      upfile="PMP.200*.txt"&lt;BR /&gt;      ;;&lt;BR /&gt;    &lt;BR /&gt;    22)&lt;BR /&gt;                              &lt;BR /&gt;      upfile="PMP.200*.txt"&lt;BR /&gt;      ;;&lt;BR /&gt;    &lt;BR /&gt;     *)&lt;BR /&gt;      print "Script only intended to run in upload mode on 3rd through 6th of each month\n"     &lt;BR /&gt;      exit 1&lt;BR /&gt;      ;;&lt;BR /&gt;  esac&lt;BR /&gt;&lt;BR /&gt;  print "Testing upload dir/file: $upload_dir/$upfile"&lt;BR /&gt;  test -e $upload_dir/$upfile&lt;BR /&gt; &lt;BR /&gt;  if [[ $? = 0 ]]&lt;BR /&gt;  then          &lt;BR /&gt;    cd $upload_dir&lt;BR /&gt;    action="put"&lt;BR /&gt; &lt;BR /&gt;    &lt;BR /&gt;    for F in $upfile&lt;BR /&gt;      do&lt;BR /&gt;        &lt;BR /&gt;        (( send_trys = 1 ))  # initialize upload loop variable&lt;BR /&gt;        sent="false"&lt;BR /&gt;        confirmed="false"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can someone please help me understand the following:&lt;BR /&gt;if [ "X$1" != "X" ]                             &lt;BR /&gt;then&lt;BR /&gt;    print " "&lt;BR /&gt;    print "invocation date:  $print_date"&lt;BR /&gt;    print " "&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;I know it is checking for a null condition but what exactly is it checking for.&lt;BR /&gt;&lt;BR /&gt;Also there are two case statements but closed only once (esac).&lt;BR /&gt;&lt;BR /&gt;Any help will be appreciated.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Jun 2009 13:09:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447223#M682892</guid>
      <dc:creator>Robert Legatie</dc:creator>
      <dc:date>2009-06-25T13:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447224#M682893</link>
      <description>&lt;!--!*#--&gt;Hi Robert:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Can someone please help me understand the following: if [ "X$1" != "X" ]&lt;BR /&gt;&lt;BR /&gt;The script is (as you said) testing to see if '$1' (the first argument passed to it on the command line) exists or not.  I would have used the second technique in the snippet below:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;if [ "X$1" != "X" ]; then&lt;BR /&gt;    echo has_value&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ ! -z "$1" ]; then&lt;BR /&gt;    echo has_value&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;As for the two case statements with only one 'esac' for closure, that's a syntax error.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 25 Jun 2009 14:00:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447224#M682893</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-25T14:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447225#M682894</link>
      <description>thanks for the response.&lt;BR /&gt;if [ ! -z "$1" ]; then&lt;BR /&gt;    echo has_value&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;what are we checking? how does it fit in when the script is executed. has_value means?&lt;BR /&gt;Pardon my ignorance.</description>
      <pubDate>Thu, 25 Jun 2009 14:18:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447225#M682894</guid>
      <dc:creator>Robert Legatie</dc:creator>
      <dc:date>2009-06-25T14:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447226#M682895</link>
      <description>Hi (again) Robert:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; what are we checking? how does it fit in when the script is executed. has_value means?&lt;BR /&gt;&lt;BR /&gt;I was trying to answer your question by example.  The script snippet is checking to see if an argument was passed ($1) to it at runtime or not.&lt;BR /&gt;&lt;BR /&gt;# cat ./showme&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;if [ "X$1" != "X" ]; then&lt;BR /&gt;    echo "has_value=$1"&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ ! -z "$1" ]; then&lt;BR /&gt;    echo "has_value=$1"&lt;BR /&gt;else&lt;BR /&gt;    echo empty&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# ./showme&lt;BR /&gt;empty&lt;BR /&gt;empty&lt;BR /&gt;&lt;BR /&gt;# ./showme 22&lt;BR /&gt;has_value=22&lt;BR /&gt;has_value=22&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 25 Jun 2009 14:49:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447226#M682895</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-25T14:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447227#M682896</link>
      <description>James you did reply to my other thread as well to the days of the week script.&lt;BR /&gt;&lt;BR /&gt;Could you please help me use that logic in the case statement below&lt;BR /&gt;&lt;BR /&gt;case $day in&lt;BR /&gt;03 | 04 | 05 | 06)&lt;BR /&gt;upfile="PMP.200*.txt"&lt;BR /&gt;;;&lt;BR /&gt;&lt;BR /&gt;22)&lt;BR /&gt;&lt;BR /&gt;upfile="PMP.200*.txt"&lt;BR /&gt;;;&lt;BR /&gt;&lt;BR /&gt;*)&lt;BR /&gt;print "Script only intended to run in upload mode on 3rd through 6th of each month\n" &lt;BR /&gt;exit 1&lt;BR /&gt;;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;I need this script to run only through Monday to Friday of each week.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 25 Jun 2009 16:42:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447227#M682896</guid>
      <dc:creator>Robert Legatie</dc:creator>
      <dc:date>2009-06-25T16:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447228#M682897</link>
      <description>&lt;!--!*#--&gt;Hi Robert:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I need this script to run only through Monday to Friday of each week&lt;BR /&gt;&lt;BR /&gt;Your code could look something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;DAY=$(date "+%w")&lt;BR /&gt;case ${DAY} in&lt;BR /&gt;    0 ) echo "Sunday --- skipping"&lt;BR /&gt;    ;;&lt;BR /&gt;    6 ) echo "Saturday --- skipping"&lt;BR /&gt;    ;;&lt;BR /&gt;    * ) echo "Goody --- a weekday!"&lt;BR /&gt;        /usr/bin/date&lt;BR /&gt;    ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 25 Jun 2009 16:53:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447228#M682897</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-25T16:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447229#M682898</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I need this script to run only through Monday to Friday of each week.&lt;BR /&gt;&lt;BR /&gt;I would use a simple if vs case:&lt;BR /&gt;day=$(date +%u)&lt;BR /&gt;if [ $day -gt 5 ]; then&lt;BR /&gt;   echo "not weekday"&lt;BR /&gt;   exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: Your code could look something like this:&lt;BR /&gt;&lt;BR /&gt;You can also use multiple values in a case label:&lt;BR /&gt;case ${DAY} in&lt;BR /&gt;0|6) echo "weekend --- skipping" ;;</description>
      <pubDate>Thu, 25 Jun 2009 23:18:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447229#M682898</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-06-25T23:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with case and if statements</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447230#M682899</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: You can also use multiple values in a case label&lt;BR /&gt;&lt;BR /&gt;Yes, TIMTOWTDI :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 25 Jun 2009 23:28:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-needed-with-case-and-if-statements/m-p/4447230#M682899</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-25T23:28:09Z</dc:date>
    </item>
  </channel>
</rss>

