<?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 scripting question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191862#M164950</link>
    <description>Is there a way that I can associate one file for another...&lt;BR /&gt;Let me explain...&lt;BR /&gt;I have a script that cats a directory for find $SCRIPTS_DIR/reset_pass*.exp -print &amp;gt; /tmp/reset_pass.input&lt;BR /&gt;&lt;BR /&gt;This file contains 4 entries reset_pass_user1 thru 4.&lt;BR /&gt;&lt;BR /&gt;I then do a for loop on /tmp/reset_pass.input that does a number of commands. &lt;BR /&gt;What I would like to do, is there is another file created before hand that is associated to user1 throught 4. login_entry_user1, login_entry_user2, etc.&lt;BR /&gt;&lt;BR /&gt;I want to try to do an I dont know if an if statement is the right way, but while going thru the for loop for reset_pass_user1,say, find the related file that was created, IE: login_entry_user1 and cat that file and place it in another file.&lt;BR /&gt;&lt;BR /&gt;I hope I explained it right.</description>
    <pubDate>Fri, 13 Feb 2004 11:53:26 GMT</pubDate>
    <dc:creator>Ratzie</dc:creator>
    <dc:date>2004-02-13T11:53:26Z</dc:date>
    <item>
      <title>scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191862#M164950</link>
      <description>Is there a way that I can associate one file for another...&lt;BR /&gt;Let me explain...&lt;BR /&gt;I have a script that cats a directory for find $SCRIPTS_DIR/reset_pass*.exp -print &amp;gt; /tmp/reset_pass.input&lt;BR /&gt;&lt;BR /&gt;This file contains 4 entries reset_pass_user1 thru 4.&lt;BR /&gt;&lt;BR /&gt;I then do a for loop on /tmp/reset_pass.input that does a number of commands. &lt;BR /&gt;What I would like to do, is there is another file created before hand that is associated to user1 throught 4. login_entry_user1, login_entry_user2, etc.&lt;BR /&gt;&lt;BR /&gt;I want to try to do an I dont know if an if statement is the right way, but while going thru the for loop for reset_pass_user1,say, find the related file that was created, IE: login_entry_user1 and cat that file and place it in another file.&lt;BR /&gt;&lt;BR /&gt;I hope I explained it right.</description>
      <pubDate>Fri, 13 Feb 2004 11:53:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191862#M164950</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-02-13T11:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191863#M164951</link>
      <description>You can't associate it as you have mentioned but if you can make the names similar.  For example if the file associated with reset_pass_user2 was called otherfile.user2 then you could find that file by reference to the "user2" part.  You could us "awk" or "expr" (expr is my favourite - why use an entire programming language just to extract a substring!) to extract the bit you need.</description>
      <pubDate>Fri, 13 Feb 2004 12:00:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191863#M164951</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-02-13T12:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191864#M164952</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Let me see if I understood it right.&lt;BR /&gt;&lt;BR /&gt;I would get the user name first from the reset_pass entry and then use it to identify&lt;BR /&gt;the login_entry.&lt;BR /&gt;&lt;BR /&gt;For ex.,&lt;BR /&gt;&lt;BR /&gt;for ENTRY in $(cat file)&lt;BR /&gt;do&lt;BR /&gt;USER=$(echo $ENTRY|awk '{FS="_";print $3}')&lt;BR /&gt;FILE=login_entry_${USER}&lt;BR /&gt;echo file is $FILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In the above your FILE is login_entry_userx. So, you can anything you want with it. For ex., if [ -f $FILE ] etc.,&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Feb 2004 12:09:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191864#M164952</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-02-13T12:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191865#M164953</link>
      <description>Not sure I understand what you are looking for, but here is a perl script that will look in the "$SCRIPTS_DIR" for filenames that match the types you are interested in. It will then copy the contents (for each user, as defined as part of the filename) into /tmp. So /tmp will have one file for each user found under the directory.&lt;BR /&gt; &lt;BR /&gt;$scripts=$ENV{"SCRIPTS_DIR"};&lt;BR /&gt;open(INP,"ls $scripts");&lt;BR /&gt;while(&lt;INP&gt;) {&lt;BR /&gt; chomp;&lt;BR /&gt; if (/(.+_)(.*)/) {&lt;BR /&gt;  $a=$1; $b=$2;&lt;BR /&gt;  if ($a eq "reset_pass_") {&lt;BR /&gt;   ($user)=split('\.',$b);&lt;BR /&gt;  } elsif ($a eq "login_entry_") {&lt;BR /&gt;   $user=$b;&lt;BR /&gt;  } else {&lt;BR /&gt;   $user="";&lt;BR /&gt;  }&lt;BR /&gt;  push(@{$hold{$user}},$_);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;foreach $user (sort keys %hold) {&lt;BR /&gt; open(OUT,"&amp;gt;/tmp/$user");&lt;BR /&gt; foreach $file (@{$hold{$user}}) {&lt;BR /&gt;  open(FIL,"&amp;lt;$scripts");&lt;BR /&gt;  while(&lt;FIL&gt;) { print OUT $_; }&lt;BR /&gt;  close(FIL);&lt;BR /&gt; }&lt;BR /&gt; close(OUT);&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;/FIL&gt;&lt;/INP&gt;</description>
      <pubDate>Fri, 13 Feb 2004 12:35:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191865#M164953</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-02-13T12:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191866#M164954</link>
      <description>Some minor issues with Sridhar's solution:&lt;BR /&gt;1) '_' in your $SCRIPTS_DIR will result in nasty problems&lt;BR /&gt;2) $SCRIPTSDIR cannot be too long, or you'll run out of commandline length in the for statement&lt;BR /&gt;&lt;BR /&gt;And I will go for a smaller program to cut your string... like Mark already mentioned. But I'm more a 'cut' fan.&lt;BR /&gt;&lt;BR /&gt;My solution would be:&lt;BR /&gt;cat &lt;FILE&gt; | while read ENTRY&lt;BR /&gt;do&lt;BR /&gt;   USER=$(basename "$ENTRY" | cut -d_ -f3)&lt;BR /&gt;   FILE=login_entry_${USER}&lt;BR /&gt;   echo $FILE&lt;BR /&gt;done&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 13 Feb 2004 15:07:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3191866#M164954</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-02-13T15:07:10Z</dc:date>
    </item>
  </channel>
</rss>

