<?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: Problem with posix script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101802#M717455</link>
    <description>First of all if you have a semi-colon in there it is not a oneliner :)... you just put it on one line.&lt;BR /&gt; &lt;BR /&gt;Also, I believe that you have a problem with all this being evaluated as a variable known as IVO.&lt;BR /&gt; &lt;BR /&gt;Your syntax looks fine, however, I count well over 300 characters... if you are trying to pass this output to a variable, I believe there is a 256 limitation on variable assignation.&lt;BR /&gt; &lt;BR /&gt;why dont you simply place your commands in a shell script then export the variable? It seems that will work better.</description>
    <pubDate>Fri, 24 Oct 2003 13:49:53 GMT</pubDate>
    <dc:creator>Todd McDaniel_1</dc:creator>
    <dc:date>2003-10-24T13:49:53Z</dc:date>
    <item>
      <title>Problem with posix script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101801#M717454</link>
      <description>Hello folks, im having problems with a one-line script. it first checks if it is on a HP-UX system, then copies and zips syslog.log and mail.log in /var/adm/syslog/  - it then empties the old files. it also puts the date into the names of the backed up files.&lt;BR /&gt;&lt;BR /&gt;the original series of commands is:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;IVO=`uname -s`; if [ "$IVO" != "HP-UX" ]; then echo "Not a HP-UX system...exiting.."; sleep 1; exit 1; fi; echo "Backing up, zipping and emptying syslog.log and mail.log"; cd /var/adm/syslog/; bdf .; for i in *.log; do j=OLD`expr "$i" : "\(.*\).log"`; cp $i $j`date -u +%e-%m-%Y`.log; &amp;gt; $i; gzip -9 $j`date -u +%e-%m-%Y`.log; bdf .; done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If I split this in 2 - it works perfectly -- watch:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;itowks02:/var/adm/syslog (root)&lt;BR /&gt;itowks02:/var/adm/syslog (root) pwd&lt;BR /&gt;/var/adm/syslog&lt;BR /&gt;itowks02:/var/adm/syslog (root) ll&lt;BR /&gt;total 230&lt;BR /&gt;-rw-r--r--   1 root       sys          20080 Oct 24 16:51 mail.log&lt;BR /&gt;-rw-r--r--   1 root       sys           9090 Oct 17 23:08 mail.log.Fri&lt;BR /&gt;-rw-r--r--   1 root       sys          10038 Oct 20 23:08 mail.log.Mon&lt;BR /&gt;-rw-r--r--   1 root       sys           9768 Oct 18 23:30 mail.log.Sat&lt;BR /&gt;-rw-r--r--   1 root       sys           9089 Oct 19 23:08 mail.log.Sun&lt;BR /&gt;-rw-r--r--   1 root       sys          10040 Oct 23 23:08 mail.log.Thu&lt;BR /&gt;-rw-r--r--   1 root       sys           9124 Oct 21 23:08 mail.log.Tue&lt;BR /&gt;-rw-r--r--   1 root       sys           9081 Oct 22 23:08 mail.log.Wed&lt;BR /&gt;-rw-r--r--   1 root       root         19164 Oct 24 16:51 syslog.log&lt;BR /&gt;drwxr-xr-x   2 root       sys           1024 Apr  9  2000 trimlogs&lt;BR /&gt;&lt;BR /&gt;itowks02:/var/adm/syslog (root) IVO=`uname -s`; if [ "$IVO" != "HP-UX" ]; then echo "Not a HP-UX system...exiting.."; sleep 1; exit 1; fi; echo "Backing up, zi&lt;BR /&gt;pping and emptying syslog.log and mail.log"; cd /var/adm/syslog/; bdf .&lt;BR /&gt;Backing up, zipping and emptying syslog.log and mail.log&lt;BR /&gt;Filesystem          kbytes    used   avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol3    8282112 2097055 5798649   27% /&lt;BR /&gt;itowks02:/var/adm/syslog (root)&lt;BR /&gt;itowks02:/var/adm/syslog (root)&lt;BR /&gt;&lt;BR /&gt;itowks02:/var/adm/syslog (root) for i in *.log; do j=OLD`expr "$i" : "\(.*\).log"`; cp $i $j`date -u +%e-%m-%Y`.log; &amp;gt; $i; gzip -9 $j`date -u +%e-%m-%Y`.log; b&lt;BR /&gt;df .; done&lt;BR /&gt;Filesystem          kbytes    used   avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol3    8282112 2097033 5798670   27% /&lt;BR /&gt;Filesystem          kbytes    used   avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol3    8282112 2097011 5798690   27% /&lt;BR /&gt;&lt;BR /&gt;itowks02:/var/adm/syslog (root) ll&lt;BR /&gt;total 142&lt;BR /&gt;-rw-r--r--   1 root       sys           1038 Oct 24 16:52 OLDmail24-10-2003.log.gz&lt;BR /&gt;-rw-r--r--   1 root       sys           1368 Oct 24 16:52 OLDsyslog24-10-2003.log.gz&lt;BR /&gt;-rw-r--r--   1 root       sys              0 Oct 24 16:52 mail.log&lt;BR /&gt;-rw-r--r--   1 root       sys           9090 Oct 17 23:08 mail.log.Fri&lt;BR /&gt;-rw-r--r--   1 root       sys          10038 Oct 20 23:08 mail.log.Mon&lt;BR /&gt;-rw-r--r--   1 root       sys           9768 Oct 18 23:30 mail.log.Sat&lt;BR /&gt;-rw-r--r--   1 root       sys           9089 Oct 19 23:08 mail.log.Sun&lt;BR /&gt;-rw-r--r--   1 root       sys          10040 Oct 23 23:08 mail.log.Thu&lt;BR /&gt;-rw-r--r--   1 root       sys           9124 Oct 21 23:08 mail.log.Tue&lt;BR /&gt;-rw-r--r--   1 root       sys           9081 Oct 22 23:08 mail.log.Wed&lt;BR /&gt;-rw-r--r--   1 root       root             0 Oct 24 16:52 syslog.log&lt;BR /&gt;drwxr-xr-x   2 root       sys           1024 Apr  9  2000 trimlogs&lt;BR /&gt;itowks02:/var/adm/syslog (root)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But if I put them together: &lt;BR /&gt;itowks02:/var/adm/syslog (root)&lt;BR /&gt;itowks02:/var/adm/syslog (root) IVO=`uname -s`; if [ "$IVO" != "HP-UX" ]; then echo "Not a HP-UX system...exiting.."; sleep 1; exit 1; fi; echo "Backing up, zi&lt;BR /&gt;pping and emptying syslog.log and mail.log"; cd /var/adm/syslog/; bdf .; for i in *.log; do j=OLD`expr "$i" : "\(.*\).log"`; cp $i $j`date -u +%e-%m-%Y`.log; &amp;gt;&lt;BR /&gt; $i; gzip -9 $j`date -u +%e-%m-%Y`.log; bdf .; done&lt;BR /&gt;itowks02:/var/adm/syslog (root) bdf .; for i in *.log; do j=OLD`expr "$i" : "\(.*\).log"`; cp $                                                             &amp;lt;&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; ^C&lt;BR /&gt;itowks02:/var/adm/syslog (root)&lt;BR /&gt;&lt;BR /&gt;I think its caused by the number of commands/characters the shell will accept before the next newline - I think I recall running into such a limit before when using C/C++/Pascal.&lt;BR /&gt;&lt;BR /&gt;Syntax is fine (I think) - there is no reason why a string of commands, which works perfectly, followed by another string of commands which work perfectly, seperated by a semicolon, should not work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It looks as if there is an unmatched quote - I would say this is because the shell only reads so far before (discarding?) the rest. So it might get as far as one quote but discard the second one.&lt;BR /&gt;&lt;BR /&gt;ivo&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Oct 2003 11:01:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101801#M717454</guid>
      <dc:creator>Tom Ellis</dc:creator>
      <dc:date>2003-10-24T11:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with posix script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101802#M717455</link>
      <description>First of all if you have a semi-colon in there it is not a oneliner :)... you just put it on one line.&lt;BR /&gt; &lt;BR /&gt;Also, I believe that you have a problem with all this being evaluated as a variable known as IVO.&lt;BR /&gt; &lt;BR /&gt;Your syntax looks fine, however, I count well over 300 characters... if you are trying to pass this output to a variable, I believe there is a 256 limitation on variable assignation.&lt;BR /&gt; &lt;BR /&gt;why dont you simply place your commands in a shell script then export the variable? It seems that will work better.</description>
      <pubDate>Fri, 24 Oct 2003 13:49:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101802#M717455</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2003-10-24T13:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with posix script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101803#M717456</link>
      <description>You are running into commandline limitations within the quoted stuff.  Break it up more. In addition to being a horrible read, you aren't gaining any efficiencies by coding it like that. &lt;BR /&gt;&lt;BR /&gt;Also, keep in mind that there will, eventually, be people other than yourself who will have to maintain these scripts if they aren't one-time runs. You have an obligation to your employer to not obfuscate your work to the point where someone else cannot do it.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;mark</description>
      <pubDate>Fri, 24 Oct 2003 15:32:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101803#M717456</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2003-10-24T15:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with posix script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101804#M717457</link>
      <description>Great, thanks for the help Todd &amp;amp; Mark. I know its a horrible read but it has to run on one line, because I have to be able to copy &amp;amp; paste it into a shell. - i work in support and ITO reports a lot of /var's too full, which I have to reduce to below a threshold. I only have a reflection session and dont want (and am probably not allowed) to put scripts on the customer servers. Also, for some reason I show up as Mark Ellis in ITRC forums, even though my name is, and I am registered as Ivo Mencke.&lt;BR /&gt;&lt;BR /&gt;thanks again,&lt;BR /&gt;&lt;BR /&gt;ivo.</description>
      <pubDate>Sat, 25 Oct 2003 16:07:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101804#M717457</guid>
      <dc:creator>Ivo Mencke</dc:creator>
      <dc:date>2003-10-25T16:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with posix script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101805#M717458</link>
      <description>Ivo&lt;BR /&gt;&lt;BR /&gt;Even if you can't or don't want to put scripts onto the server, maybe you have the ability to edit your own .profile?&lt;BR /&gt;&lt;BR /&gt;If so, why don't you code your main processing into a function ? At the end of your .profile, add&lt;BR /&gt;&lt;BR /&gt;function backupandzip&lt;BR /&gt;{&lt;BR /&gt; echo "Backing up, zipping and emptying syslog.log and mail.log"&lt;BR /&gt; cd /var/adm/syslog/&lt;BR /&gt; bdf .&lt;BR /&gt; for i in *.log&lt;BR /&gt; do j=OLD`expr "$i" : "\(.*\).log"`&lt;BR /&gt; cp $i $j`date -u +%e-%m-%Y`.log&lt;BR /&gt; &amp;gt; $i&lt;BR /&gt; gzip -9 $j`date -u +%e-%m-%Y`.log&lt;BR /&gt; bdf .&lt;BR /&gt; done&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;You can also abbreviate the test clause and your on-liner can then become:&lt;BR /&gt;&lt;BR /&gt;[[ $(uname -s) = "HP-UX" ]] &amp;amp;&amp;amp; backupandzip || echo "Not HP-UX ..."&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Mon, 27 Oct 2003 03:48:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101805#M717458</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-27T03:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with posix script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101806#M717459</link>
      <description>The reason it is not working in a single line has to do with the shell, which replaces the wild-chars. You do multiple multiple times a '*.log', which will be replaced the moment you run that command line. If everything is in one command line, they will be replaced by the same filenames. But you alter them in the first for loop.&lt;BR /&gt;&lt;BR /&gt;The best way is to make it an alias or script. It depends on the way you login to the client machine on what your best solution might be. You could, for instance, copy the script to /tmp, run it, and remove it, leaving no rubbish on the clients machine but still do your stuff automatically. If the script is tested well, this will make it a lot saver then to copy-and-past.&lt;BR /&gt;&lt;BR /&gt;Just my 2 cents...</description>
      <pubDate>Tue, 28 Oct 2003 09:20:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-posix-script/m-p/3101806#M717459</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-10-28T09:20:56Z</dc:date>
    </item>
  </channel>
</rss>

