<?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: shell script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5724955#M638352</link>
    <description>&lt;P&gt;So you're finding the differences between file1 and file2, and saving the list of differences to file3.&lt;/P&gt;&lt;P&gt;You show that the content of file3 is literally:&lt;/P&gt;&lt;PRE&gt;Only in file2: data&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your command "put $file3" does not work because there is no environment variable named "file3": environment variables are not the same as files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The diff command also produces output like "Only in &amp;lt;name&amp;gt;: &amp;lt;filename&amp;gt;" only when &amp;lt;name&amp;gt; is a directory. So I guess &lt;FONT face="courier new,courier"&gt;file1&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;file2&lt;/FONT&gt; are actually directories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A different syntax could be used to read the contents of &lt;FONT face="courier new,courier"&gt;file3&lt;/FONT&gt; and use them on the command line. There are two ways to do this:&lt;/P&gt;&lt;PRE&gt;put $(cat file3)&lt;BR /&gt;put $(&amp;lt; file3)&lt;/PRE&gt;&lt;P&gt;If &lt;FONT face="courier new,courier"&gt;file3&lt;/FONT&gt; has the content you showed, this would result in a command like "&lt;FONT face="courier new,courier"&gt;put Only in file2: data&lt;/FONT&gt;", which will not work. You would have to remove the "&lt;FONT face="courier new,courier"&gt;Only in file2:&lt;/FONT&gt; " part before using the rest to build your "put" command. And if the current working directory of the "put" command is the same as when you ran the "diff" command, the command you actually need is more likely "put file2/data".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it is guaranteed that the diff command will always identify one and only one file for transfer in directory &lt;FONT face="courier new,courier"&gt;file2&lt;/FONT&gt;, you might do something like this:&lt;/P&gt;&lt;PRE&gt;put file2/$(grep "^Only in file2:" &amp;lt;file3 | awk '{print $4}')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;To understand this, you must look inside the $( ... ) construct first.&lt;/P&gt;&lt;P&gt;First, the grep command will find the right line in file3, ignoring any other lines in the file, and piping the right line to awk. The awk command will pick the 4th word from the line, ignoring everything else. This should be the word "data". Now, the entire $( ... ) construct will be replaced with the awk output, i.e. the command line will ultimately be equivalent to:&lt;/P&gt;&lt;PRE&gt;put file2/data&lt;/PRE&gt;&lt;P&gt;If there might be more than one file to transfer, you would need to do something like this: (the reason why there was no need to put ../file3 instead of file3 is left as an exercise for the reader :-)&lt;/P&gt;&lt;PRE&gt;diff file1 file2 &amp;gt; file3&lt;BR /&gt;ftp -n -i -v 10.40.40.26 &amp;lt;&amp;lt;EOT&lt;BR /&gt;user admin Welcome456&lt;BR /&gt;prompt&lt;BR /&gt;lcd file2
mput $(grep "^Only in file2:" &amp;lt;file3 | awk '{print $4}')&lt;BR /&gt;EOT&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2012 09:49:50 GMT</pubDate>
    <dc:creator>Matti_Kurkela</dc:creator>
    <dc:date>2012-07-16T09:49:50Z</dc:date>
    <item>
      <title>shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5722919#M638349</link>
      <description>&lt;P&gt;i was write one script for file transfer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;script&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ftp -d -n -i -v 10.40.40.26 &amp;lt;&amp;lt;EOT&lt;BR /&gt;user admin Welcome456&lt;BR /&gt;lcd&lt;BR /&gt;put *.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;the above sciprt upload *.txt file to one window FTP account. i want to upload the (/home/rajesh )in this path we have 5 files , i want to upload today created files not folder , how to write the script&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2012 09:16:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5722919#M638349</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-14T09:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5722937#M638350</link>
      <description>&lt;P&gt;&amp;gt;I want to upload today created files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can put the files modified today:&lt;/P&gt;&lt;P&gt;ftp -n -i -v 10.40.40.26 &amp;lt;&amp;lt;EOF&lt;BR /&gt;user admin Welcome456&lt;/P&gt;&lt;P&gt;prompt&lt;/P&gt;&lt;P&gt;lcd directory&lt;/P&gt;&lt;P&gt;mput $(find . -type f -mtime -1)&lt;/P&gt;&lt;P&gt;EOF&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2012 13:37:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5722937#M638350</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-07-16T13:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5724759#M638351</link>
      <description>diff file1 file2 &amp;gt; file3&lt;BR /&gt;&lt;BR /&gt;more file3&lt;BR /&gt;Only in file2: data&lt;BR /&gt;&lt;BR /&gt;i want to tranfer the file called data&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;pls find the below command is not working, please help me&lt;BR /&gt;&lt;BR /&gt;put $file3</description>
      <pubDate>Mon, 16 Jul 2012 08:33:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5724759#M638351</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-16T08:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5724955#M638352</link>
      <description>&lt;P&gt;So you're finding the differences between file1 and file2, and saving the list of differences to file3.&lt;/P&gt;&lt;P&gt;You show that the content of file3 is literally:&lt;/P&gt;&lt;PRE&gt;Only in file2: data&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your command "put $file3" does not work because there is no environment variable named "file3": environment variables are not the same as files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The diff command also produces output like "Only in &amp;lt;name&amp;gt;: &amp;lt;filename&amp;gt;" only when &amp;lt;name&amp;gt; is a directory. So I guess &lt;FONT face="courier new,courier"&gt;file1&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;file2&lt;/FONT&gt; are actually directories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A different syntax could be used to read the contents of &lt;FONT face="courier new,courier"&gt;file3&lt;/FONT&gt; and use them on the command line. There are two ways to do this:&lt;/P&gt;&lt;PRE&gt;put $(cat file3)&lt;BR /&gt;put $(&amp;lt; file3)&lt;/PRE&gt;&lt;P&gt;If &lt;FONT face="courier new,courier"&gt;file3&lt;/FONT&gt; has the content you showed, this would result in a command like "&lt;FONT face="courier new,courier"&gt;put Only in file2: data&lt;/FONT&gt;", which will not work. You would have to remove the "&lt;FONT face="courier new,courier"&gt;Only in file2:&lt;/FONT&gt; " part before using the rest to build your "put" command. And if the current working directory of the "put" command is the same as when you ran the "diff" command, the command you actually need is more likely "put file2/data".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it is guaranteed that the diff command will always identify one and only one file for transfer in directory &lt;FONT face="courier new,courier"&gt;file2&lt;/FONT&gt;, you might do something like this:&lt;/P&gt;&lt;PRE&gt;put file2/$(grep "^Only in file2:" &amp;lt;file3 | awk '{print $4}')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;To understand this, you must look inside the $( ... ) construct first.&lt;/P&gt;&lt;P&gt;First, the grep command will find the right line in file3, ignoring any other lines in the file, and piping the right line to awk. The awk command will pick the 4th word from the line, ignoring everything else. This should be the word "data". Now, the entire $( ... ) construct will be replaced with the awk output, i.e. the command line will ultimately be equivalent to:&lt;/P&gt;&lt;PRE&gt;put file2/data&lt;/PRE&gt;&lt;P&gt;If there might be more than one file to transfer, you would need to do something like this: (the reason why there was no need to put ../file3 instead of file3 is left as an exercise for the reader :-)&lt;/P&gt;&lt;PRE&gt;diff file1 file2 &amp;gt; file3&lt;BR /&gt;ftp -n -i -v 10.40.40.26 &amp;lt;&amp;lt;EOT&lt;BR /&gt;user admin Welcome456&lt;BR /&gt;prompt&lt;BR /&gt;lcd file2
mput $(grep "^Only in file2:" &amp;lt;file3 | awk '{print $4}')&lt;BR /&gt;EOT&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2012 09:49:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5724955#M638352</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2012-07-16T09:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5725377#M638353</link>
      <description>&lt;P&gt;&amp;gt;There are two ways to do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No need to mention using an evil cat.&amp;nbsp; ;-)&amp;nbsp; $(&amp;lt; file3) is the "right" way for a real shell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could combine the diff, grep and awk into one:&lt;BR /&gt;mput $(diff file1 file2 | awk '/^Only in file2:/ {print $4}')&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2012 13:36:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5725377#M638353</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-07-16T13:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5725637#M638354</link>
      <description>thanks dennis and matti,&lt;BR /&gt;&lt;BR /&gt;from mattia advise today i created the script , but mput not upload two file, it will upload only one file.&lt;BR /&gt;&lt;BR /&gt;dennis tomorrow i try your script , if any doubt i will touch you ,thanks once again</description>
      <pubDate>Mon, 16 Jul 2012 17:22:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5725637#M638354</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-16T17:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726103#M638355</link>
      <description>i am using yout script, but difference output given two files , but only one file is uploading&lt;BR /&gt;&lt;BR /&gt;please find the output&lt;BR /&gt;&lt;BR /&gt;diff wel sur | awk '/^Only in sur:/ {print $4}'&lt;BR /&gt;data1&lt;BR /&gt;data2&lt;BR /&gt;&lt;BR /&gt;but we when he execute the scruipt data1 only upload.&lt;BR /&gt;&lt;BR /&gt;pls advise&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2012 02:53:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726103#M638355</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-17T02:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726145#M638356</link>
      <description>how to simply fy the output&lt;BR /&gt;&lt;BR /&gt;i need data1 data2,&lt;BR /&gt;but the output comes&lt;BR /&gt;data1&lt;BR /&gt;date2</description>
      <pubDate>Tue, 17 Jul 2012 03:20:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726145#M638356</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-17T03:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726243#M638357</link>
      <description>pls help me any one this is urgent&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2012 04:45:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726243#M638357</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-17T04:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726329#M638358</link>
      <description>&lt;P&gt;&amp;gt;but the output comes (separate lines)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oops.&amp;nbsp; Either we need to change the newline to a space, use printf or just have multiple puts:&lt;/P&gt;&lt;P&gt;ftp -n -i -v 10.40.40.26 &amp;lt;&amp;lt;EOF&lt;BR /&gt;user admin Welcome456&lt;BR /&gt;lcd file2&lt;/P&gt;&lt;P&gt;$(diff file1 file2 | awk '/^Only in file2:/ {print "put", $4}')&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # separate puts&lt;/P&gt;&lt;P&gt;EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ftp -n -i -v 10.40.40.26 &amp;lt;&amp;lt;EOF&lt;BR /&gt;user admin Welcome456&lt;BR /&gt;prompt&lt;BR /&gt;lcd file2&lt;/P&gt;&lt;P&gt;mput $(diff file1 file2 | awk '/^Only in file2:/ {printf "%s ", $4}')&amp;nbsp; # combine lines&lt;/P&gt;&lt;P&gt;EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2012 07:05:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726329#M638358</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-07-17T07:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help (ftp)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726361#M638359</link>
      <description>thank you so much dennis, script working fine</description>
      <pubDate>Tue, 17 Jul 2012 05:49:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5726361#M638359</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-07-17T05:49:45Z</dc:date>
    </item>
  </channel>
</rss>

