<?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 Urgent Help in Scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973991#M543312</link>
    <description>Hi, Below is one bash script in which i want to copy one file from dir A to Dir B and if its get successsful then it will remove that file from source directory&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/bash&lt;BR /&gt;cp /home/admin/atul/OBC/nit1 /home/admin/atul/KBC/nit1&lt;BR /&gt;$var = `echo "$?"`  ####### Checking the status of previous command&lt;BR /&gt;if [$val = 0 ]; then&lt;BR /&gt;rm /home/admin/atul/OBC/nit1&lt;BR /&gt;else&lt;BR /&gt;        echo "Copy Failed";&lt;BR /&gt;fi&lt;BR /&gt;+++++++++++++++++++++++++++++++++++++++++&lt;BR /&gt;&lt;BR /&gt;but while executing script i am getting this error:&lt;BR /&gt;&lt;BR /&gt;ssmove.sh: line 3: =: command not found&lt;BR /&gt;ssmove.sh: line 4: [: -eq: unary operator expected&lt;BR /&gt;Copy Failed&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 03 Apr 2007 01:45:53 GMT</pubDate>
    <dc:creator>network_4</dc:creator>
    <dc:date>2007-04-03T01:45:53Z</dc:date>
    <item>
      <title>Urgent Help in Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973991#M543312</link>
      <description>Hi, Below is one bash script in which i want to copy one file from dir A to Dir B and if its get successsful then it will remove that file from source directory&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/bash&lt;BR /&gt;cp /home/admin/atul/OBC/nit1 /home/admin/atul/KBC/nit1&lt;BR /&gt;$var = `echo "$?"`  ####### Checking the status of previous command&lt;BR /&gt;if [$val = 0 ]; then&lt;BR /&gt;rm /home/admin/atul/OBC/nit1&lt;BR /&gt;else&lt;BR /&gt;        echo "Copy Failed";&lt;BR /&gt;fi&lt;BR /&gt;+++++++++++++++++++++++++++++++++++++++++&lt;BR /&gt;&lt;BR /&gt;but while executing script i am getting this error:&lt;BR /&gt;&lt;BR /&gt;ssmove.sh: line 3: =: command not found&lt;BR /&gt;ssmove.sh: line 4: [: -eq: unary operator expected&lt;BR /&gt;Copy Failed&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Apr 2007 01:45:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973991#M543312</guid>
      <dc:creator>network_4</dc:creator>
      <dc:date>2007-04-03T01:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent Help in Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973992#M543313</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If u want to copy and delete after success why&lt;BR /&gt;don't u use mv command.&lt;BR /&gt;&lt;BR /&gt;$ mv /home/admin/atul/OBC/nit1 /home/admin/atul/KBC/nit1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also while setting variables don't use $ sign.&lt;BR /&gt;and don't use spaces on either side of =.&lt;BR /&gt;--$var = `echo "$?"` ####### Checking the status of previous command&lt;BR /&gt;&lt;BR /&gt;Use &lt;BR /&gt;&lt;BR /&gt;var=`echo "$?"` ####### Checking the status of previous command.&lt;BR /&gt;And no need to store $? in var, u can directly compare $? like following&lt;BR /&gt;&lt;BR /&gt;if [ $? -eq 0 ]; then&lt;BR /&gt;Also&lt;BR /&gt;&lt;BR /&gt;--if [$val = 0 ]; then&lt;BR /&gt;&lt;BR /&gt;since $? returns a number, to compare a number u have to use -eq instead of =, &lt;BR /&gt;because = compares strings.&lt;BR /&gt;&lt;BR /&gt;-Santosh</description>
      <pubDate>Tue, 03 Apr 2007 02:03:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973992#M543313</guid>
      <dc:creator>SANTOSH S. MHASKAR</dc:creator>
      <dc:date>2007-04-03T02:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent Help in Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973993#M543314</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I think you need just a &lt;SPACE&gt; between&lt;BR /&gt;"[" and "$val". &lt;BR /&gt;&lt;BR /&gt;another way:&lt;BR /&gt;&lt;BR /&gt;# cp A B &amp;amp;&amp;amp; rm A || echo ERROR.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;&lt;/SPACE&gt;</description>
      <pubDate>Tue, 03 Apr 2007 02:06:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973993#M543314</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2007-04-03T02:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent Help in Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973994#M543315</link>
      <description>Hi,&lt;BR /&gt;not a fan of bash, so this is my guess:&lt;BR /&gt;1. line 3 &lt;BR /&gt;val = `echo "$?"`&lt;BR /&gt;2. line 4&lt;BR /&gt;if [ $val -eq 0 ]&lt;BR /&gt;&lt;BR /&gt;Although I think line 3 should be val = $?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please also read:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt; on how to reward any useful answers given to your questions.&lt;BR /&gt;&lt;BR /&gt;So far you have only awarded points to 1 of 33 answers !&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Apr 2007 02:06:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973994#M543315</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-04-03T02:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent Help in Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973995#M543316</link>
      <description>Thanks.. Issue closed</description>
      <pubDate>Tue, 03 Apr 2007 02:22:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973995#M543316</guid>
      <dc:creator>network_4</dc:creator>
      <dc:date>2007-04-03T02:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent Help in Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973996#M543317</link>
      <description>Line 3: when storing a value to a variable, you must not put "$" in front of the variable name. As is, when the variable expansion is done, this command line expands to:&lt;BR /&gt;&lt;BR /&gt;= `echo "0"`&lt;BR /&gt;&lt;BR /&gt;which looks like you're trying to run a command named "=". That's why the error message is "command not found".&lt;BR /&gt;&lt;BR /&gt;Line 4: you're using an uninitialized variable, for two reasons. &lt;BR /&gt;1) the previous command did not succeed&lt;BR /&gt;2) you have a typo: in the line 3, you store to "var", here you request the value of "val".&lt;BR /&gt;If a variable might have an empty value, you should always put double quotes around it.&lt;BR /&gt;After variable expansion, this command line expands to:&lt;BR /&gt;&lt;BR /&gt;if [ = 0 ]; then&lt;BR /&gt;&lt;BR /&gt;The error message comes from the "[" command (also known as "test", usually implemented as shell internal command but available as a separate binary too). For it "-eq" and "=" are synonymous, so it displays "=" as "-eq". &lt;BR /&gt;&lt;BR /&gt;If the expression between the brackets begins with an operator, it must be the kind of operator that takes only one argument, i.e. an unary argument. As the unquoted variable expanded to nothing at all, it broke your expression.&lt;BR /&gt;&lt;BR /&gt;Your script also seems over-complex.&lt;BR /&gt;You could do it more simply like this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;if cp /home/admin/atul/OBC/nit1 /home/admin/atul/KBC/nit1&lt;BR /&gt;then&lt;BR /&gt;rm /home/admin/atul/OBC/nit1&lt;BR /&gt;else&lt;BR /&gt;echo "Copy Failed"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The "if" command can be used to test whether the return code of any command is 0 or not-0. &lt;BR /&gt;&lt;BR /&gt;The "[" command evaluates the expression given to it and sets  its return code according to the truth value of the expression. &lt;BR /&gt;&lt;BR /&gt;Combining these two creates the familiar "if [ ... ]" structure.</description>
      <pubDate>Tue, 03 Apr 2007 02:31:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-help-in-scripting/m-p/3973996#M543317</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2007-04-03T02:31:47Z</dc:date>
    </item>
  </channel>
</rss>

