<?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: Running a copy command stored into a variable with/without gzip in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922070#M761722</link>
    <description>All excellent replied and so much of a help.  It is very much appreciated.  &lt;BR /&gt;&lt;BR /&gt;This script is a component of a larger set of scripts which is used to refresh a test oracle database from a production system by doing a fully-automated "clone" of the production oracle system.  In this case, we want to produce a gzipped copy of the source files, and not gzip the source file itself.  &lt;BR /&gt;&lt;BR /&gt;That's the explanation for these approaches to the coding with the redirects.&lt;BR /&gt;&lt;BR /&gt;Gil</description>
    <pubDate>Wed, 10 Jan 2007 14:15:35 GMT</pubDate>
    <dc:creator>Gilbert Standen_1</dc:creator>
    <dc:date>2007-01-10T14:15:35Z</dc:date>
    <item>
      <title>Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922062#M761714</link>
      <description>I'm having problem with the following.  Here is the code I run.&lt;BR /&gt;&lt;BR /&gt;if [ "$GZIP" = 'N' ]&lt;BR /&gt;then&lt;BR /&gt;grep $sfname ${REFDIR}/${TSID}/file_map | sed 's/^/cp -p /' | read CMD&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ "$GZIP" = 'Y' ]&lt;BR /&gt;then&lt;BR /&gt;grep $sfname ${REFDIR}/${TSID}/file_map | sed 's/^/gzip &amp;lt; /' | sed 's/dbf/dbf &amp;gt; /' | sed 's/$/\.gz/' | read CMD&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ "$RUNN" = 'Y' ]&lt;BR /&gt;then&lt;BR /&gt;echo $CMD&lt;BR /&gt;$CMD&lt;BR /&gt;else&lt;BR /&gt;echo $CMD&lt;BR /&gt;fi&lt;BR /&gt;echo ' '&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Here is the output if GZIP=Y:&lt;BR /&gt;&lt;BR /&gt;gzip &amp;lt; /global/u123/app/oracle/oradata/PROD/banlob.dbf &amp;gt; /u09/app/oracle/oradata/EVAL/PROD_banlob.dbf.gz&lt;BR /&gt;gzip: Y: No such file or directory&lt;BR /&gt;gzip: &amp;lt;: No such file or directory&lt;BR /&gt;&lt;BR /&gt;You see how gzip gives errors when it runs "$CMD" if it is the gzip version.  Looking at the above code, I don't get these errors when I set it to GZIP=N.  In that case, $CMD is set to the following line:&lt;BR /&gt;&lt;BR /&gt;cp -p /global/u123/app/oracle/oradata/PROD/banlob.dbf /u09/app/oracle/oradata/EVAL/PROD_banlob.dbf&lt;BR /&gt;&lt;BR /&gt;which runs fine within the script.&lt;BR /&gt;&lt;BR /&gt;So why will one command successfully store to $CMD and run, while the gzip version, stores to CMD ok (I can echo it and cut and paste it to the command line and it runs fine) but when the script tries to run it as $CMD it gives the errors show above (and I don't know where the "Y" comes from in the gzip error -- there aren't even any "Y's" in the code being run!!).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 07 Jan 2007 15:48:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922062#M761714</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2007-01-07T15:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922063#M761715</link>
      <description>When assigning anything but a simple command to a variable and then executing, use eval as in:&lt;BR /&gt; &lt;BR /&gt;eval "$CMD"&lt;BR /&gt; &lt;BR /&gt;enclosing $CMD in quotes will take care of any special characters like spaces and redirection characters like &amp;lt; or &amp;gt;.</description>
      <pubDate>Sun, 07 Jan 2007 19:02:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922063#M761715</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-01-07T19:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922064#M761716</link>
      <description>Hi Bill,&lt;BR /&gt;I tried your suggestion, but I still get the error.  Here is the revised script and execution result.  I still get this "gzip: Y: No such file or directory" message.  And, as shown, I can still cut and paste the echoed command and it runs fine!&lt;BR /&gt;Gil&lt;BR /&gt;&lt;BR /&gt;fsscttest:oracle:CONV$ vi test_copy_files.ksh&lt;BR /&gt;"test_copy_files.ksh" 36 lines, 653 characters&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;export SSID=$1&lt;BR /&gt;export TSID=$2&lt;BR /&gt;export RUNN=$3&lt;BR /&gt;export GZIP=$4&lt;BR /&gt;&lt;BR /&gt;export REFDIR=/home/oracle/refresh&lt;BR /&gt;&lt;BR /&gt;export sfname='refresh.current.dbf'&lt;BR /&gt;echo $sfname&lt;BR /&gt;&lt;BR /&gt;if [ "$GZIP" = 'N' ]&lt;BR /&gt;then&lt;BR /&gt;grep $sfname ${REFDIR}/${TSID}/file_map | sed 's/^/cp -p /' | read CMD&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ "$GZIP" = 'Y' ]&lt;BR /&gt;then&lt;BR /&gt;grep $sfname ${REFDIR}/${TSID}/file_map | sed 's/^/gzip &amp;lt; /' | sed 's/dbf/dbf &amp;gt; /' | sed 's/$/\.gz/' | read CMD&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ "$RUNN" = 'Y' ]&lt;BR /&gt;then&lt;BR /&gt;echo $CMD&lt;BR /&gt;sleep 5&lt;BR /&gt;eval "$CMD"&lt;BR /&gt;else&lt;BR /&gt;echo $CMD&lt;BR /&gt;fi&lt;BR /&gt;~&lt;BR /&gt;"test_copy_files.ksh" 30 lines, 476 characters&lt;BR /&gt;fsscttest:oracle:CONV$ test_copy_files.ksh PROD EVAL Y Y&lt;BR /&gt;refresh.current.dbf&lt;BR /&gt;gzip &amp;lt; /home/oracle/refresh/EVAL/refresh.current.dbf &amp;gt; /home/oracle/refresh/refresh.current.dbf.gz&lt;BR /&gt;gzip: Y: No such file or directory&lt;BR /&gt;fsscttest:oracle:CONV$ ls -l /home/oracle/refresh/EVAL/refresh.current.dbf&lt;BR /&gt;-rw-r-----   1 oracle   dba      291031040 Jan  7 12:37 /home/oracle/refresh/EVAL/refresh.current.dbf&lt;BR /&gt;fsscttest:oracle:CONV$ gzip &amp;lt; /home/oracle/refresh/EVAL/refresh.current.dbf &amp;gt; /home/oracle/refresh/refresh.current.dbf.gz&lt;BR /&gt;fsscttest:oracle:CONV$&lt;BR /&gt;&lt;BR /&gt;(command runs ok when cut and pasted to command line)</description>
      <pubDate>Wed, 10 Jan 2007 12:38:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922064#M761716</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2007-01-10T12:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922065#M761717</link>
      <description>A couple of things that *might* be issues:&lt;BR /&gt;&lt;BR /&gt;1) gzip *uses* $GZIP to determine gzip opts, at least in later versions, so you may be inducing side-effects using it in your script.  I'd try renaming to something like GZ_switch?&lt;BR /&gt;&lt;BR /&gt;2) I've never tried, nor do I see in the man pages that "gzip &amp;lt; file.name &amp;gt; file.name.gz" is supported.  I'd remove the redirected std input "&amp;lt;", as it expects a filename anyway.</description>
      <pubDate>Wed, 10 Jan 2007 13:20:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922065#M761717</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-01-10T13:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922066#M761718</link>
      <description>oh yeah, btw: (1) above explains the "Y"</description>
      <pubDate>Wed, 10 Jan 2007 13:21:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922066#M761718</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-01-10T13:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922067#M761719</link>
      <description>OldSchool,&lt;BR /&gt;&lt;BR /&gt;That did the trick!  It works now in the script as a result of your suggestion #1. Appreciated!&lt;BR /&gt;&lt;BR /&gt;As to suggestion #2, I had previously been using a different approach, i.e.:&lt;BR /&gt;&lt;BR /&gt;cat filename | gzip -1 -c &amp;gt; filename.gz&lt;BR /&gt;&lt;BR /&gt;which also works.  Would this be better?  Testing shows that as expected it runs about twice as fast and produces a file that is about 21% larger than the "vanilla" gzip.</description>
      <pubDate>Wed, 10 Jan 2007 13:50:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922067#M761719</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2007-01-10T13:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922068#M761720</link>
      <description>"gzip &amp;lt; file &amp;gt; file.gz" works fine. "cat file | gzip -c &amp;gt; file.gz" should be about the same in all respects if you specify the same compression level. Use whichever one you like better.</description>
      <pubDate>Wed, 10 Jan 2007 14:05:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922068#M761720</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2007-01-10T14:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922069#M761721</link>
      <description>ok,&lt;BR /&gt;&lt;BR /&gt;the -1 is the compression level 1-9, where 1 is least/fastest and 9 is slowest/most compression.  w/o the option the default is approx 6, middle of the road compression with middle of the road speed.  that's why the file is somewhat bigger than the "vanilla" gzip.&lt;BR /&gt;&lt;BR /&gt;what I meant w/ #2 was I've never seen&lt;BR /&gt;"gzip &amp;lt; a &amp;gt; a.gz" before&lt;BR /&gt;&lt;BR /&gt;the "cat" approach you noted keeps the original file and produces a .gz file.  the usual command "gzip a" will *replace* a w/ a.gz&lt;BR /&gt;&lt;BR /&gt;so....it's gonna depend on what you want when your done zipping.....</description>
      <pubDate>Wed, 10 Jan 2007 14:09:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922069#M761721</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-01-10T14:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922070#M761722</link>
      <description>All excellent replied and so much of a help.  It is very much appreciated.  &lt;BR /&gt;&lt;BR /&gt;This script is a component of a larger set of scripts which is used to refresh a test oracle database from a production system by doing a fully-automated "clone" of the production oracle system.  In this case, we want to produce a gzipped copy of the source files, and not gzip the source file itself.  &lt;BR /&gt;&lt;BR /&gt;That's the explanation for these approaches to the coding with the redirects.&lt;BR /&gt;&lt;BR /&gt;Gil</description>
      <pubDate>Wed, 10 Jan 2007 14:15:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922070#M761722</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2007-01-10T14:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Running a copy command stored into a variable with/without gzip</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922071#M761723</link>
      <description>ok, so just as a followup I scripted it as GZSW where GZSW is of the command line form [Y|N]:[1-9] and then within the script&lt;BR /&gt;echo $GZSW | cut -f1 -d':' | read GZS1&lt;BR /&gt;echo $GZSW | cut -f2 -d':' | read GZS2&lt;BR /&gt;so now a user of the script can choose (faster/larger) or (slower/smaller) (1-9) as they wish as well as choosing whether to GZIP or not. I used a compound variable because I've already got 9 total variables in the calling script so the caller will pass GZSW as GZS1:GZS2</description>
      <pubDate>Wed, 10 Jan 2007 15:20:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-a-copy-command-stored-into-a-variable-with-without-gzip/m-p/3922071#M761723</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2007-01-10T15:20:56Z</dc:date>
    </item>
  </channel>
</rss>

