<?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: Can anyone find a bug in this code?? shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865036#M773124</link>
    <description>Hello Amonamon,&lt;BR /&gt;&lt;BR /&gt;I guess that the second parameter you pass to your script looks like a date. &lt;BR /&gt;&lt;BR /&gt;If you want this to be excecuted by cron with an updated date you, perhaps, wrote in your crontab something like :&lt;BR /&gt;&lt;BR /&gt;/path/script1 file1 $( date +'%Y%m%d' )&lt;BR /&gt;&lt;BR /&gt;This does not work well because the % character is interpreted as a separator by cron.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;JPH&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 20 Sep 2006 06:21:21 GMT</pubDate>
    <dc:creator>Jean-Philippe HENRY_1</dc:creator>
    <dc:date>2006-09-20T06:21:21Z</dc:date>
    <item>
      <title>Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865029#M773117</link>
      <description>I have done a script and IT WORKS JUST PERFECT from command line...but in cron it has problems executing...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;nawk -F"|" '          &lt;BR /&gt;{ s=substr($104,2,18)}&lt;BR /&gt;{b[s] ++s}&lt;BR /&gt;END { for (i in b) print i, b[i] } ' $1 &amp;gt; /path/to/files/TranId_w$2&lt;BR /&gt;&lt;BR /&gt;q=`cat /path/to/files/TranId_w$2 | wc -l`&lt;BR /&gt;echo $q &amp;gt; /path/to/files/zaCGSN&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;nawk -F"|" -v x=$2 -v w=$(cat zaCGSN) '&lt;BR /&gt;{u=u+1; l=l+$66}&lt;BR /&gt;($66 != 0)&amp;amp;&amp;amp;($110 == 1)&amp;amp;&amp;amp;($111 == 0) { a=a+1; s=s+$66}&lt;BR /&gt;END { print x"|"u"|"l"|"w"|"s } ' $1 &amp;gt;&amp;gt; statistic&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rm /path/to/files/TranId_w$2&lt;BR /&gt;rm zaCGSN &lt;BR /&gt;&lt;BR /&gt;./ftp_PC statistic&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and I execute it ./script1 file1 20061212&lt;BR /&gt;I think problem is somewhere in second nawk..becouse in cron I can see TranId_w$2 created every day but statistic is not updated..&lt;BR /&gt;&lt;BR /&gt;can anyone help me with debug..&lt;BR /&gt;&lt;BR /&gt;Regards..</description>
      <pubDate>Tue, 19 Sep 2006 00:59:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865029#M773117</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2006-09-19T00:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865030#M773118</link>
      <description>When starting scripts from cron use full names - for exmple instead of cat use /sbin/cat.&lt;BR /&gt;&lt;BR /&gt;ivan</description>
      <pubDate>Tue, 19 Sep 2006 01:10:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865030#M773118</guid>
      <dc:creator>Ivan Krastev</dc:creator>
      <dc:date>2006-09-19T01:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865031#M773119</link>
      <description>Hi Amonamon,&lt;BR /&gt;&lt;BR /&gt;When you run it from the command line the script inherits the variables defined in your shell, most notably the PATH. &lt;BR /&gt;Cron has no such environment, you need to tell it everything it should know. So either you could define a PATH variable at the beginning of your job, or you should fully qualify all commands you use. So, if you run nawk from /usr/local/bin make sure you specify "/usr/local/bin/nawk" instead of just using "nawk".&lt;BR /&gt;&lt;BR /&gt;HtH,&lt;BR /&gt;&lt;BR /&gt;Jan</description>
      <pubDate>Tue, 19 Sep 2006 01:44:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865031#M773119</guid>
      <dc:creator>J.C. Sepp_1</dc:creator>
      <dc:date>2006-09-19T01:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865032#M773120</link>
      <description>As mentioned, your command line is actually a shell login environment. To see what you are missing, type the command:&lt;BR /&gt; &lt;BR /&gt;env&lt;BR /&gt; &lt;BR /&gt;In cron, that same command produces:&lt;BR /&gt; &lt;BR /&gt;HOME=user's-home-directory           LOGNAME=user's-login-id           PATH=/usr/bin:/usr/sbin:.           SHELL=/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt;And that's it. When you write *any* script, it is a good idea to never assume anything, whether it is $PATH or $PWD. Changes I would make:&lt;BR /&gt; &lt;BR /&gt;Always use the interpreter line as line 1:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;Always explicitly state your PATH - never use the current one:&lt;BR /&gt; &lt;BR /&gt;export PATH=/usr/bin&lt;BR /&gt; &lt;BR /&gt;Never use any patch that is relative (ie, ./ftp)&lt;BR /&gt; &lt;BR /&gt;The grave accents have been deprecated for 10 years. Use the construct $() as in:&lt;BR /&gt; &lt;BR /&gt;q=$(cat /path/to/files/TranId_w$2 | wc -l)</description>
      <pubDate>Tue, 19 Sep 2006 01:59:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865032#M773120</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-09-19T01:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865033#M773121</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;in addition to the above suggestions, I want to warn about the construct w=$(...) in:&lt;BR /&gt;nawk -F"|" -v x=$2 -v w=$(cat zaCGSN) '...&lt;BR /&gt;&lt;BR /&gt;If the file zaCGSN contains one or more blanks, there will be a syntax error this (n)awk command.&lt;BR /&gt;Use&lt;BR /&gt;nawk -F"|" -v x=$2 -v w="$(cat zaCGSN)" '...&lt;BR /&gt;instead.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 19 Sep 2006 05:02:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865033#M773121</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-09-19T05:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865034#M773122</link>
      <description>I see that in&lt;BR /&gt;&lt;BR /&gt;echo $q &amp;gt; /path/to/files/zaCGSN&lt;BR /&gt;&lt;BR /&gt;you use the full path to the file "zaCGSN", and in&lt;BR /&gt;&lt;BR /&gt;nawk -F"|" -v x=$2 -v w=$(cat zaCGSN) '&lt;BR /&gt;&lt;BR /&gt;you use a relative path as if you were in the same directory.&lt;BR /&gt;&lt;BR /&gt;With no full path to the file I suppose that the cat command will fail.</description>
      <pubDate>Tue, 19 Sep 2006 05:10:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865034#M773122</guid>
      <dc:creator>Alfredo Garcia Martino</dc:creator>
      <dc:date>2006-09-19T05:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865035#M773123</link>
      <description>....and the full path to "ftp_PC"</description>
      <pubDate>Tue, 19 Sep 2006 06:51:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865035#M773123</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2006-09-19T06:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865036#M773124</link>
      <description>Hello Amonamon,&lt;BR /&gt;&lt;BR /&gt;I guess that the second parameter you pass to your script looks like a date. &lt;BR /&gt;&lt;BR /&gt;If you want this to be excecuted by cron with an updated date you, perhaps, wrote in your crontab something like :&lt;BR /&gt;&lt;BR /&gt;/path/script1 file1 $( date +'%Y%m%d' )&lt;BR /&gt;&lt;BR /&gt;This does not work well because the % character is interpreted as a separator by cron.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;JPH&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2006 06:21:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865036#M773124</guid>
      <dc:creator>Jean-Philippe HENRY_1</dc:creator>
      <dc:date>2006-09-20T06:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone find a bug in this code?? shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865037#M773125</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;to complete JPH remark:&lt;BR /&gt;if you want to use the percent sign in a crontab commandline, you have to double it:&lt;BR /&gt;/path/script1 file1 $(date +'%%Y%%m%%d')&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 20 Sep 2006 07:12:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-anyone-find-a-bug-in-this-code-shell-script/m-p/3865037#M773125</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-09-20T07:12:43Z</dc:date>
    </item>
  </channel>
</rss>

