<?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: Script output. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998649#M718547</link>
    <description>usually when this situation happens, i.e. scripts runs manually but not via cron, is because cron's environment is different from the users.&lt;BR /&gt;&lt;BR /&gt;courtesy of bill hassell:&lt;BR /&gt;&lt;BR /&gt;cron NEVER logs in like a normal user so nothing in /etc/profile or .profile is run. All cron jobs should set PATH explicitly (actually, all reliable scripts should do this) to avoid issues like this. And of course, specialized variables that may have been added to login profiles should also be coded into cron scripts. Use the set command in your cron job to show what your current environment contains.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 16 Jun 2003 15:57:33 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2003-06-16T15:57:33Z</dc:date>
    <item>
      <title>Script output.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998648#M718546</link>
      <description>This is part of a script I am trying to run from the cron.  The script works fine manually but doesn't work from the cron.  The output from the "if ping 149.197.238.180 -n 3 | grep '100% packet loss'" line doesn't get filtered by grep because it is running from cron.  The output from the ping statement either gos to email or std out.&lt;BR /&gt;&lt;BR /&gt;########################################################&lt;BR /&gt;if [ "$BB6509LC" -ne 1 ]&lt;BR /&gt;then&lt;BR /&gt; if ping 149.197.238.180 -n 3 | grep '100% packet loss'&lt;BR /&gt; then&lt;BR /&gt;  telalertc -i JeffMartin -m "Critical Switch Unreachable: BB-6509-LANCENTER"&lt;BR /&gt;  BB6509LC=1&lt;BR /&gt; fi&lt;BR /&gt;fi&lt;BR /&gt;########################################################&lt;BR /&gt;if [ "$BB6MSFCDSTBY" -ne 1 ]&lt;BR /&gt;then&lt;BR /&gt; if ping 149.197.238.180 -n 3 | grep '100% packet loss'&lt;BR /&gt; then&lt;BR /&gt;  telalertc -i JeffMartin -m "Critical Switch Unreachable: BB-6MSFC-DASD-STBY"&lt;BR /&gt;  BB6MSFCDSTBY=1&lt;BR /&gt; fi&lt;BR /&gt;fi&lt;BR /&gt;########################################################&lt;BR /&gt;&lt;BR /&gt;How do I get around this so my script works properly?&lt;BR /&gt;&lt;BR /&gt;Thanks, &lt;BR /&gt;&lt;BR /&gt;Jeff Martin</description>
      <pubDate>Mon, 16 Jun 2003 15:45:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998648#M718546</guid>
      <dc:creator>Jeff Martin_3</dc:creator>
      <dc:date>2003-06-16T15:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script output.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998649#M718547</link>
      <description>usually when this situation happens, i.e. scripts runs manually but not via cron, is because cron's environment is different from the users.&lt;BR /&gt;&lt;BR /&gt;courtesy of bill hassell:&lt;BR /&gt;&lt;BR /&gt;cron NEVER logs in like a normal user so nothing in /etc/profile or .profile is run. All cron jobs should set PATH explicitly (actually, all reliable scripts should do this) to avoid issues like this. And of course, specialized variables that may have been added to login profiles should also be coded into cron scripts. Use the set command in your cron job to show what your current environment contains.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Jun 2003 15:57:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998649#M718547</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-06-16T15:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script output.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998650#M718548</link>
      <description>Jeff,&lt;BR /&gt;&lt;BR /&gt;Can you try to enter the full path name for ping as well as for grep?  Then retry.&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Mon, 16 Jun 2003 16:01:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998650#M718548</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-06-16T16:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script output.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998651#M718549</link>
      <description>Chances are is that /usr/sbin isn't on the PATH. For some *strange* reason somebody in the wide world of SYSV decided that ping should live in /usr/sbin instead of /usr/bin...&lt;BR /&gt;&lt;BR /&gt;The solution is to explicitly use /usr/sbin/ping.&lt;BR /&gt;&lt;BR /&gt;BTW with your script you will get rubbish emailed to you; you can suppress the output of grep by doing:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;if /usr/sbin/ping 149.197.238.180 -n 3 | grep -q '100% packet loss'&lt;BR /&gt;then&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;dave</description>
      <pubDate>Mon, 16 Jun 2003 16:05:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998651#M718549</guid>
      <dc:creator>David Lodge</dc:creator>
      <dc:date>2003-06-16T16:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script output.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998652#M718550</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You'll also need the full path of the telalertc command too.&lt;BR /&gt;&lt;BR /&gt;It would also be wise to have a #!/usr/bin/sh at the top of the script too (if you haven't already!)&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;&lt;BR /&gt;Darren.</description>
      <pubDate>Mon, 16 Jun 2003 16:07:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998652#M718550</guid>
      <dc:creator>Darren Prior</dc:creator>
      <dc:date>2003-06-16T16:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Script output.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998653#M718551</link>
      <description>Hi Jeff,&lt;BR /&gt; I do this pretty often... just redireting the output of the ping to a temp file, then grep the temp&lt;BR /&gt;&lt;BR /&gt;&amp;gt;/tmp/isp.test&lt;BR /&gt;/usr/etc/ping -s64 -c1 $isp &amp;gt;/tmp/isp.test&lt;BR /&gt;&lt;BR /&gt;if [ `cat /tmp/isp.test | grep -c "1 packets received"` = 0 ]&lt;BR /&gt;  then</description>
      <pubDate>Tue, 17 Jun 2003 10:59:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output/m-p/2998653#M718551</guid>
      <dc:creator>Renda Skandier</dc:creator>
      <dc:date>2003-06-17T10:59:55Z</dc:date>
    </item>
  </channel>
</rss>

