<?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: Environment Variables in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595463#M33336</link>
    <description>Rajkumar,&lt;BR /&gt;&lt;BR /&gt;You can use the same script to achive what you need.&lt;BR /&gt;&lt;BR /&gt;You can provide inputs to this script and it works as well with  some modifications.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;if[ $# -ne 3 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Usage: $0 directory expiry match"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;DIR=${X:-$1}&lt;BR /&gt;EXPIRE=${E:-$2}&lt;BR /&gt;MATCH=${M:-$3}&lt;BR /&gt;&lt;BR /&gt;DIRs=`ll -d $DIR`&lt;BR /&gt;&lt;BR /&gt;for I in $DIRs&lt;BR /&gt;do&lt;BR /&gt;if [ -d $I ]&lt;BR /&gt;then&lt;BR /&gt;echo $I &amp;gt;&amp;gt; /tmp/valid$$&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;TOTALDIR=`wc -l /tmp/valid$$|awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;if [ $TOTALDIR -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;logger "$0: No valid directories found"&lt;BR /&gt;exit 1&lt;BR /&gt;else&lt;BR /&gt;logger "$0: $TOTALDIR number of dirs found.. deleting"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for I in `cat /tmp/valid$$`&lt;BR /&gt;do&lt;BR /&gt;COUNT=0&lt;BR /&gt;find $I -name $MATCH -mtime $EXPIRE|while read FILE&lt;BR /&gt;do&lt;BR /&gt;rm $FILE &amp;amp;&amp;amp; logger "$0 : $FILE deleted" &lt;BR /&gt;COUNT=$(expr $COUNT+1)&lt;BR /&gt;done&lt;BR /&gt;logger "$0: deleted $COUNT files in $I"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;rm /tmp/valid$$&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;//END of the script&lt;BR /&gt;&lt;BR /&gt;Now this script will take three arguments&lt;BR /&gt;&lt;BR /&gt;#input.ksh directory expiry match_string&lt;BR /&gt;&lt;BR /&gt;For ex.,&lt;BR /&gt;&lt;BR /&gt;#input.sh /database/X* 4 X_*&lt;BR /&gt;&lt;BR /&gt;will delete all the files under /database/X* directories that haven't been modified since 4days that match the string X_*.&lt;BR /&gt;&lt;BR /&gt;I suggest you use this script on some temporary directories and see if it works for permitations and combinations of inputs. I don't have a system in front of me. It doesn't do error checking. For ex., input.ksh test test new will give out errors and may also do damage. So, you need to be careful. To do error checking is a big business.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
    <pubDate>Wed, 17 Oct 2001 00:09:17 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2001-10-17T00:09:17Z</dc:date>
    <item>
      <title>Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595454#M33327</link>
      <description>Hai all,&lt;BR /&gt;&lt;BR /&gt;I have attached a complete document of my requirement regarding the shell script and environment variables.&lt;BR /&gt;&lt;BR /&gt;Its urjent..Please provide me a help..&lt;BR /&gt;&lt;BR /&gt;Thanking you&lt;BR /&gt;&lt;BR /&gt;Rajkumar</description>
      <pubDate>Tue, 16 Oct 2001 06:26:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595454#M33327</guid>
      <dc:creator>Rajkumar_3</dc:creator>
      <dc:date>2001-10-16T06:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595455#M33328</link>
      <description>find . -type d -exec &amp;lt;script&amp;gt; {} \;&lt;BR /&gt;&lt;BR /&gt;and modify the script so it gets the directory as an argument.&lt;BR /&gt;&lt;BR /&gt;aha, and make sure you are on the top directory of the directory structure that you want to clean.</description>
      <pubDate>Tue, 16 Oct 2001 06:34:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595455#M33328</guid>
      <dc:creator>Eugen Cocalea</dc:creator>
      <dc:date>2001-10-16T06:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595456#M33329</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;isn't it sufficient for you to run just this part of the script (tune the location to your needs):&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;COUNT=0 &lt;BR /&gt;&lt;BR /&gt;find /Database/J??/* -name "X_*" -mtime +3 | while read FILE ; do&lt;BR /&gt;rm $FILE &amp;amp;&amp;amp; logger "$0 : $FILE deleted" &lt;BR /&gt;(( COUNT = COUNT + 1 )) &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;if [ "$COUNT" -gt 0 ] ; then &lt;BR /&gt;logger "$0 : $COUNT files removed" &lt;BR /&gt;else &lt;BR /&gt;logger "$0 : No matching files found" &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
      <pubDate>Tue, 16 Oct 2001 06:41:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595456#M33329</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2001-10-16T06:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595457#M33330</link>
      <description>Hai,&lt;BR /&gt;&lt;BR /&gt;I didnt understand what you are telling me..&lt;BR /&gt;&lt;BR /&gt;My query is to delete the files from the multiple directories..Can you give me complete picture&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rajkumar</description>
      <pubDate>Tue, 16 Oct 2001 06:42:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595457#M33330</guid>
      <dc:creator>Rajkumar_3</dc:creator>
      <dc:date>2001-10-16T06:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595458#M33331</link>
      <description>Hai Thierry,&lt;BR /&gt;&lt;BR /&gt;That means it will search all the files from the database directory untill this files starting with X_&lt;FILENAME.EXT&gt; founds. Is that true???&lt;BR /&gt;&lt;BR /&gt;I am trying out with your script..&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rajkumar&lt;/FILENAME.EXT&gt;</description>
      <pubDate>Tue, 16 Oct 2001 06:47:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595458#M33331</guid>
      <dc:creator>Rajkumar_3</dc:creator>
      <dc:date>2001-10-16T06:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595459#M33332</link>
      <description>hi Rajkumar,&lt;BR /&gt;&lt;BR /&gt;find /Database/....   -name "X_*"  ....&lt;BR /&gt;will give you *ALL* files starting with "X_" in /Database and ALL its subdirectories.  You do not have to specify directory per directory, unless you want to skip some specific directories.&lt;BR /&gt;BTW it's always a good idea to test those find&amp;amp;delete scripts first with find&amp;amp;display ;)&lt;BR /&gt;&lt;BR /&gt;good luck,&lt;BR /&gt;Thierry</description>
      <pubDate>Tue, 16 Oct 2001 06:54:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595459#M33332</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2001-10-16T06:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595460#M33333</link>
      <description>Hi Rajkumar,&lt;BR /&gt;&lt;BR /&gt;Personally, if you want to control the directories externally, I'd put them into a file, and read the file in the script:&lt;BR /&gt;&lt;BR /&gt;========================================&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;cat file_containing_list_of_directories | while read DIR ; do&lt;BR /&gt;&lt;BR /&gt; if [ ! -d "$DIR" ] ; then&lt;BR /&gt;  logger "$0 : $DIR not found"&lt;BR /&gt;  exit 1&lt;BR /&gt; fi&lt;BR /&gt;&lt;BR /&gt; COUNT=0&lt;BR /&gt;&lt;BR /&gt; find $DIR -name "X_*" -mtime +3 | while read FILE ; do&lt;BR /&gt;  rm $FILE &amp;amp;&amp;amp; logger "$0 : $DIR - $FILE deleted"&lt;BR /&gt;  COUNT=$(expr $COUNT + 1)&lt;BR /&gt; done&lt;BR /&gt;&lt;BR /&gt; if [ "$COUNT" -gt 0 ] ; then&lt;BR /&gt;  logger "$0 : $DIR - $COUNT files removed"&lt;BR /&gt; else&lt;BR /&gt;  logger "$0 : No matching files found"&lt;BR /&gt; fi&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;===========================================&lt;BR /&gt;&lt;BR /&gt;Then you can leave the cronjob as it is, and edit the external file to suit.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Tue, 16 Oct 2001 07:05:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595460#M33333</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-10-16T07:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595461#M33334</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please provide more input. Are there any other directories under /Database that you don't want to touch? Do you only want to erase from the specific directories you have in the file? I believe this questions you can answer, right?&lt;BR /&gt;&lt;BR /&gt;E.</description>
      <pubDate>Tue, 16 Oct 2001 08:47:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595461#M33334</guid>
      <dc:creator>Eugen Cocalea</dc:creator>
      <dc:date>2001-10-16T08:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595462#M33335</link>
      <description>Hai,&lt;BR /&gt;&lt;BR /&gt;Yes . I have a standard directories which i have to delete..But some times the directories may change..At that time the script dosent workout,because we are declaring the Environment variable and passing it into the script..I have also input parameters.Suppose i have a file which was created on 1st 09:00 AM..So this file has to be deleted for every 3 days and it should be depend on time and date also..&lt;BR /&gt;That means Preservation period : (3 days to delete a file). If they want to change it to 4 days ..&lt;BR /&gt;&lt;BR /&gt;Please advise me.&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rajkumar&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Oct 2001 23:46:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595462#M33335</guid>
      <dc:creator>Rajkumar_3</dc:creator>
      <dc:date>2001-10-16T23:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595463#M33336</link>
      <description>Rajkumar,&lt;BR /&gt;&lt;BR /&gt;You can use the same script to achive what you need.&lt;BR /&gt;&lt;BR /&gt;You can provide inputs to this script and it works as well with  some modifications.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;if[ $# -ne 3 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Usage: $0 directory expiry match"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;DIR=${X:-$1}&lt;BR /&gt;EXPIRE=${E:-$2}&lt;BR /&gt;MATCH=${M:-$3}&lt;BR /&gt;&lt;BR /&gt;DIRs=`ll -d $DIR`&lt;BR /&gt;&lt;BR /&gt;for I in $DIRs&lt;BR /&gt;do&lt;BR /&gt;if [ -d $I ]&lt;BR /&gt;then&lt;BR /&gt;echo $I &amp;gt;&amp;gt; /tmp/valid$$&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;TOTALDIR=`wc -l /tmp/valid$$|awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;if [ $TOTALDIR -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;logger "$0: No valid directories found"&lt;BR /&gt;exit 1&lt;BR /&gt;else&lt;BR /&gt;logger "$0: $TOTALDIR number of dirs found.. deleting"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for I in `cat /tmp/valid$$`&lt;BR /&gt;do&lt;BR /&gt;COUNT=0&lt;BR /&gt;find $I -name $MATCH -mtime $EXPIRE|while read FILE&lt;BR /&gt;do&lt;BR /&gt;rm $FILE &amp;amp;&amp;amp; logger "$0 : $FILE deleted" &lt;BR /&gt;COUNT=$(expr $COUNT+1)&lt;BR /&gt;done&lt;BR /&gt;logger "$0: deleted $COUNT files in $I"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;rm /tmp/valid$$&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;//END of the script&lt;BR /&gt;&lt;BR /&gt;Now this script will take three arguments&lt;BR /&gt;&lt;BR /&gt;#input.ksh directory expiry match_string&lt;BR /&gt;&lt;BR /&gt;For ex.,&lt;BR /&gt;&lt;BR /&gt;#input.sh /database/X* 4 X_*&lt;BR /&gt;&lt;BR /&gt;will delete all the files under /database/X* directories that haven't been modified since 4days that match the string X_*.&lt;BR /&gt;&lt;BR /&gt;I suggest you use this script on some temporary directories and see if it works for permitations and combinations of inputs. I don't have a system in front of me. It doesn't do error checking. For ex., input.ksh test test new will give out errors and may also do damage. So, you need to be careful. To do error checking is a big business.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2001 00:09:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595463#M33336</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-17T00:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Environment Variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595464#M33337</link>
      <description>Hai &lt;BR /&gt;Once again &lt;BR /&gt;&lt;BR /&gt;I need to pass two parameters:&lt;BR /&gt;a) The files stating with "X_" and&lt;BR /&gt;b) Retained time for deleting the renamed file (or)         Retained time for deleting the non-renamed file.&lt;BR /&gt;    (ie.,Time based)&lt;BR /&gt;Note: That means users will FTP from the remote server                         to the local server.So once the file is in the local                         server it will be renamed to "X_&lt;FILENAME&gt;".&lt;BR /&gt;&lt;BR /&gt;so If i pass the paramters like &lt;BR /&gt;variable1= X_ and time=1 (ie 1 hour) &lt;BR /&gt;&lt;BR /&gt;It has to check the two conditions and file has to be deleted.&lt;BR /&gt;&lt;BR /&gt;Is it possible like that to develop a shell script like that..&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Rajkumar&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 17 Oct 2001 02:04:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables/m-p/2595464#M33337</guid>
      <dc:creator>Rajkumar_3</dc:creator>
      <dc:date>2001-10-17T02:04:07Z</dc:date>
    </item>
  </channel>
</rss>

