<?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 Help Needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493175#M845720</link>
    <description>You can try with a script as like,&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;# check files&lt;BR /&gt;&lt;BR /&gt;# User input&lt;BR /&gt;echo "Enter your input"&lt;BR /&gt;read input&lt;BR /&gt;&lt;BR /&gt;# check&lt;BR /&gt;if [[ -z $input ]]&lt;BR /&gt;then&lt;BR /&gt;    echo "ERROR: User input $input is blank"&lt;BR /&gt;    exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;rm -f /tmp/testlog&lt;BR /&gt;&lt;BR /&gt;# Grep in the a* starting files&lt;BR /&gt;for file in `find . -type f -name "a*"`&lt;BR /&gt;do&lt;BR /&gt;  grep $input $file &amp;gt;/tmp/testlog&lt;BR /&gt;  if [[ $? -eq 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    cat /tmp/testlog&lt;BR /&gt;  else&lt;BR /&gt;    echo "ERROR: Used input $input is not file $file"&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;rm -f /tmp/testlog&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;### end ###&lt;BR /&gt;&lt;BR /&gt;Let me know if you have issues.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
    <pubDate>Fri, 25 Feb 2005 04:12:41 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2005-02-25T04:12:41Z</dc:date>
    <item>
      <title>Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493170#M845715</link>
      <description>Hey everyone,&lt;BR /&gt;&lt;BR /&gt;I am wanting to write a script to do something like the following.  Sorry if this seems easy to some of you, but scripting is not my strength:&lt;BR /&gt;&lt;BR /&gt;# ls a directory &amp;gt; file&lt;BR /&gt;# Ask the user for input&lt;BR /&gt;# If the input is not in the file, echo an error&lt;BR /&gt;# If the input is a blank, space, or ENTER, echo an error&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Bobby</description>
      <pubDate>Thu, 24 Feb 2005 20:23:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493170#M845715</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2005-02-24T20:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493171#M845716</link>
      <description>Bobby,&lt;BR /&gt;&lt;BR /&gt;You can write this way&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;DIR=/tmp/some&lt;BR /&gt;ls $DIR &amp;gt; /tmp/file&lt;BR /&gt;echo "Please enter a file name : \c"&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;read file&lt;BR /&gt;[[ "a$file" = "a" ]] &amp;amp;&amp;amp; continue&lt;BR /&gt;grep -q $file /tmp/file&lt;BR /&gt;[[ $? != 0 ]] &amp;amp;&amp;amp; echo "File does not exist"&lt;BR /&gt;break&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 20:40:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493171#M845716</guid>
      <dc:creator>Rajeev Tyagi</dc:creator>
      <dc:date>2005-02-24T20:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493172#M845717</link>
      <description>By redirecting "ls" out put to a file and searching for&lt;BR /&gt;a user supplied string in it, you are basically trying to&lt;BR /&gt;findout if the a file with user supplied name exists in&lt;BR /&gt;that directory of not. To do this, a simpler way &lt;BR /&gt;would be:&lt;BR /&gt;&lt;BR /&gt;DIR="/your_dir"&lt;BR /&gt;echo "Enter file name"&lt;BR /&gt;read file&lt;BR /&gt;if [ $FILE = "" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Illegal file name"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -a $DIR/file ]&lt;BR /&gt;then&lt;BR /&gt;    echo "File exists"&lt;BR /&gt;else&lt;BR /&gt;    echo "File not found"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 20:51:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493172#M845717</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-02-24T20:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493173#M845718</link>
      <description>Thanks...that will help a lot!!&lt;BR /&gt;&lt;BR /&gt;How can I modify this so that I can grep out any file in the ls listing that starts with a "d" ?  Thanks again.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 21:50:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493173#M845718</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2005-02-24T21:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493174#M845719</link>
      <description>To search a file which begins with "a" then,&lt;BR /&gt;&lt;BR /&gt;ls a*&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Fri, 25 Feb 2005 03:58:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493174#M845719</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-02-25T03:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493175#M845720</link>
      <description>You can try with a script as like,&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;# check files&lt;BR /&gt;&lt;BR /&gt;# User input&lt;BR /&gt;echo "Enter your input"&lt;BR /&gt;read input&lt;BR /&gt;&lt;BR /&gt;# check&lt;BR /&gt;if [[ -z $input ]]&lt;BR /&gt;then&lt;BR /&gt;    echo "ERROR: User input $input is blank"&lt;BR /&gt;    exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;rm -f /tmp/testlog&lt;BR /&gt;&lt;BR /&gt;# Grep in the a* starting files&lt;BR /&gt;for file in `find . -type f -name "a*"`&lt;BR /&gt;do&lt;BR /&gt;  grep $input $file &amp;gt;/tmp/testlog&lt;BR /&gt;  if [[ $? -eq 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    cat /tmp/testlog&lt;BR /&gt;  else&lt;BR /&gt;    echo "ERROR: Used input $input is not file $file"&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;rm -f /tmp/testlog&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;### end ###&lt;BR /&gt;&lt;BR /&gt;Let me know if you have issues.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Fri, 25 Feb 2005 04:12:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493175#M845720</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-02-25T04:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493176#M845721</link>
      <description>Hi Bobby,&lt;BR /&gt;I will do this way:&lt;BR /&gt;Say my script name is prg and written in korn shell.&lt;BR /&gt;&lt;BR /&gt;# chmod +x prg1.sh&lt;BR /&gt;# cat prg&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;list=`ls $1`&lt;BR /&gt;echo " Enter File Name: \n"&lt;BR /&gt;read j&lt;BR /&gt;for i in $list&lt;BR /&gt;do&lt;BR /&gt;if [ "$i" = "$j" ]&lt;BR /&gt;then&lt;BR /&gt;echo "\n Your file exists in the directory \n"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;echo "\n Your file doesn't exists in the directory \n"&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;# ls /directory&lt;BR /&gt;file1  file2  file3&lt;BR /&gt;#&lt;BR /&gt;# ./prg directory&lt;BR /&gt; Enter File Name:&lt;BR /&gt;&lt;BR /&gt;file6&lt;BR /&gt;&lt;BR /&gt; Your file doesn't exists in the directory&lt;BR /&gt;&lt;BR /&gt;# ./prg directory&lt;BR /&gt; Enter File Name:&lt;BR /&gt;&lt;BR /&gt;file3&lt;BR /&gt;&lt;BR /&gt; Your file exists in the directory&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;Regards,</description>
      <pubDate>Fri, 25 Feb 2005 04:59:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493176#M845721</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-02-25T04:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493177#M845722</link>
      <description>Hi Booby,&lt;BR /&gt;Modified scritp to list files starting with "a".&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;list=`ls $1 | grep ^a`&lt;BR /&gt;echo " Enter File Name: \n"&lt;BR /&gt;read j&lt;BR /&gt;for i in $list&lt;BR /&gt;do&lt;BR /&gt;if [ "$i" = "$j" ]&lt;BR /&gt;then&lt;BR /&gt;echo "\n Your file exists in the directory \n"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;echo "\n Your file doesn't exists in the directory \n"&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Regards,</description>
      <pubDate>Fri, 25 Feb 2005 05:38:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493177#M845722</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-02-25T05:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493178#M845723</link>
      <description>Thanks everyone!!!  This has worked out wonderfully!!!</description>
      <pubDate>Wed, 02 Mar 2005 22:19:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-needed/m-p/3493178#M845723</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2005-03-02T22:19:07Z</dc:date>
    </item>
  </channel>
</rss>

