title: Ksh and if statements
body: <p>I have done very little programming in C++, and I am not really understanding how to use code in KornShell (ksh) on the Knoppix OS. The resources given to us by the professor has been little, so it is hard to work out. The two text books we have for class talks mostly about commands in variations of UNIX, though little to do with ksh.</p>
  
  <p>Write a shell script that accepts exactly one argument which must be a positive integer. (My second one has two)</p>
  
  <p><strong>Ksh Code:</strong></p>
  
  <pre><code>NUMBER=$1
  read -p NUMBER
  # Test that one argument was input.
  if [[ $# -ne 1 ]];then
    echo "Please enter an integer as an argument"
    exit 1
  elif [[ $NUMBER -le 0 ]];then # Test value of argument is less than or equal to zero
      echo "Please enter a number &gt; 0" 
      exit 1
  fi
  
  while [["$NUMBER" -ne 1]];do
      printf $NUMBER
  if [[$NUMBER -gt 1]];then
          printf ","
      fi
  NUMBER=$(($NUMBER-1))
  done
  printf $NUMBER
  </code></pre>
  
  <p>When I run this from the shell I keep getting "Please enter an integer as an argument" as an output, though the entry was 3, or something like that.</p>
  
  <p>I noticed that there was not anything for user input, so I tried to enter this myself with </p>
  
  <pre><code>read -p NUMBER
  </code></pre>
  
  <p>before the if statement.  </p>
  
  <p>What am I missing from the code to continue on with the rest of the script to be run?</p>