<?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: Unix Developer Guide - Please post your Tips. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785363#M821497</link>
    <description>I like to use a lot of functions in my script, it makes debugging and maintenance much easier and increase readability. For example ..&lt;BR /&gt;function whoareyou {&lt;BR /&gt;[[ `whoami` != root ]] &amp;amp;&amp;amp; { print "Need superuser to run this."; exit 1; }&lt;BR /&gt;}&lt;BR /&gt;The function "whoareyou" can then be called later in the main program. You can even have different programmers code different functions, it makes distribution of work much easier.&lt;BR /&gt;..just my quick $0.02&lt;BR /&gt;</description>
    <pubDate>Tue, 13 Aug 2002 19:51:39 GMT</pubDate>
    <dc:creator>S.K. Chan</dc:creator>
    <dc:date>2002-08-13T19:51:39Z</dc:date>
    <item>
      <title>Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785349#M821483</link>
      <description>Hello Gurus:&lt;BR /&gt;&lt;BR /&gt; I am in the process of Creating a Unix Developer's Guide possibly with examples to point out the dos and don't in the shell programming, etc. I am looking forward to Inputs from all gurus for this. Please contribute generously.&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Joe.</description>
      <pubDate>Tue, 13 Aug 2002 18:20:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785349#M821483</guid>
      <dc:creator>joe_91</dc:creator>
      <dc:date>2002-08-13T18:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785350#M821484</link>
      <description>Definately don't:&lt;BR /&gt;&lt;BR /&gt;cd /tmp; rm -fR .*&lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;Marty &lt;WHO&gt;&lt;/WHO&gt;</description>
      <pubDate>Tue, 13 Aug 2002 18:24:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785350#M821484</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-08-13T18:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785351#M821485</link>
      <description>For me....&lt;BR /&gt;&lt;BR /&gt;Comments:&lt;BR /&gt;Do put remarks/comments in your script.&lt;BR /&gt;Do put your name as the author, so we know who to ask.&lt;BR /&gt;Do remember to comment/author/date anything you change &amp;amp; maybe why.&lt;BR /&gt;&lt;BR /&gt;Common sense:&lt;BR /&gt;Do keep your scripts in a logical place..or maybe all in one place.&lt;BR /&gt;Do use a naming standard that makes sense as to what the script is.  (Ex:start_oracle_payroll  not franks_st)&lt;BR /&gt;&lt;BR /&gt;Just a thought,&lt;BR /&gt;Rita&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 18:38:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785351#M821485</guid>
      <dc:creator>Rita C Workman</dc:creator>
      <dc:date>2002-08-13T18:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785352#M821486</link>
      <description>Use some kind of source code control.&lt;BR /&gt;Comment, comment, comment.&lt;BR /&gt;When using temporary files, use $$ (process ID) to make the file name unique.&lt;BR /&gt;Remove all temporary files when the script is done. Remember to do this even if the script exits early on an error condition.&lt;BR /&gt;Test for error conditions and produce a useful error message that will help resolve the problem.&lt;BR /&gt;&lt;BR /&gt;Tom&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 18:39:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785352#M821486</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-08-13T18:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785353#M821487</link>
      <description>Tom:&lt;BR /&gt;&lt;BR /&gt; Can you provide an example Please..&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Joe.</description>
      <pubDate>Tue, 13 Aug 2002 18:43:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785353#M821487</guid>
      <dc:creator>joe_91</dc:creator>
      <dc:date>2002-08-13T18:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785354#M821488</link>
      <description>Keep the goal of solving the problem foremost. Don't kill yourself writing a script when another shell or language could solve the problem easier or be more maintainable. I have seen some scripts that solve a problem - but are very complex and difficult to understand - let alone maintain. I am sure that any problem can be solved with shell scripts - but some should not be. Be aware of differences in shells that you can use to your advantage to solve a problem. Don't be stuck with one shell, one syntax. To borrow from someone else - just my $.02 worth.</description>
      <pubDate>Tue, 13 Aug 2002 18:54:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785354#M821488</guid>
      <dc:creator>Dave Chamberlin</dc:creator>
      <dc:date>2002-08-13T18:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785355#M821489</link>
      <description>$$ is the shell variable that contains the process ID of the currently running process. So you can do&lt;BR /&gt;&lt;BR /&gt;echo $$&lt;BR /&gt;&lt;BR /&gt;and you will get the PID of the shell - you can also see this in the output of "ps".&lt;BR /&gt;&lt;BR /&gt;TMP_DIR=/tmp&lt;BR /&gt;TMP_FILE=${TMP_DIR}/script$$&lt;BR /&gt;echo $TMP_FILE&lt;BR /&gt;&lt;BR /&gt;should produce something like:&lt;BR /&gt;&lt;BR /&gt;/tmp/script29803&lt;BR /&gt;&lt;BR /&gt;This will be different each time the script is run, since it will be in a sub-shell with a unique PID.&lt;BR /&gt;&lt;BR /&gt;So you won't write over your own temporary files, and won't have a conflict with someone else's temporary files.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Tue, 13 Aug 2002 18:56:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785355#M821489</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-08-13T18:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785356#M821490</link>
      <description>1) Rather than relying upon explicit rm statements to do cleanup of temp files, it is much better to handle that via a trap so that the files get removed even if the scripts receives an n'rupt.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;PID=${$}&lt;BR /&gt;T1=${TDIR}/T${PID}_1.txt&lt;BR /&gt;T2=${TDIR}/T${PID}_2.txt&lt;BR /&gt;T3=${TDIR}/T${PID}_3.txt&lt;BR /&gt;&lt;BR /&gt;trap 'eval rm -f ${T1} ${T2} ${T3}' 0 1 2 3 15&lt;BR /&gt;&lt;BR /&gt;xxxxxxxxxxx&lt;BR /&gt;xxxxxxxxxxx&lt;BR /&gt;&lt;BR /&gt;Now the temp files will be removed if the script exits normally or receives signals 1, 2, 3, or 15.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2) It almost all cases readability is favored over efficiency. Very often I tend to write code in several clear steps that could be combined into fewer statements simply to make maintenance easier.&lt;BR /&gt;&lt;BR /&gt;Now, just to make you mad. I would have new developers learn only the basic shell scripting techniques and then have then master&lt;BR /&gt;Perl. In the long run, they will be far more productive and there is then very little need to learn awk, sed, grep, tr ... . The cross-platform abilities of Perl make it my weapon of choice for most tasks these days. Even most of the stuff that I once had to do in C or C++, I can now usually do in Perl and it executes almost as fast.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:00:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785356#M821490</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-08-13T19:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785357#M821491</link>
      <description>Thanks Clay. That was Brilliant!!! Thanks for the great response. I wish it goes on...&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Joe.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:16:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785357#M821491</guid>
      <dc:creator>joe_91</dc:creator>
      <dc:date>2002-08-13T19:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785358#M821492</link>
      <description>Hey Joe,&lt;BR /&gt;&lt;BR /&gt;some points for scripts:&lt;BR /&gt;- always set the $PATH first&lt;BR /&gt;- never include the current directory&lt;BR /&gt;- always set the interpreter using the "#!/..." syntax in the very first line&lt;BR /&gt;- "unset" the shell-variables you don't need any more&lt;BR /&gt;- test for interactivity (ot the lack of) before using any "tty" command (like "stty", or "tabs", or such)&lt;BR /&gt;- always use "--" in "set" commands before appending the data&lt;BR /&gt;- always test for the exitance of files before overwriting/creating them (especially with "&amp;gt;" and "&amp;gt;&amp;gt;")&lt;BR /&gt;- always check the error/exit code&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Wodisch&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:29:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785358#M821492</guid>
      <dc:creator>Wodisch_1</dc:creator>
      <dc:date>2002-08-13T19:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785359#M821493</link>
      <description>Joe,&lt;BR /&gt;&lt;BR /&gt;the header of my scripts are of nearly the same structure. This helps me in "re"learning my own scripts when I have to make corrections/modifications years after the first writing. I recommend to do so, too. The structure of the header is as follows:&lt;BR /&gt;&lt;BR /&gt;1) Write a short text (just a few lines) that describes in very few words what your script is doing, on the top of the script.&lt;BR /&gt;&lt;BR /&gt;2) Below the line "# HISTORY", write a short paragraph  to explain what circumstances led to write this script. Explain why this script is needed.&lt;BR /&gt;&lt;BR /&gt;3) Below the line "# USAGE", give the syntax how the script must be used. For that, use the syntax as is shown in nearly every command man page.&lt;BR /&gt;&lt;BR /&gt;4) Below the line "# AUTHOR", write the name(s) of the author(s) and the date, when the script seems to be finished "the first time".&lt;BR /&gt;&lt;BR /&gt;5) Below the line "# MODIFICATIONS", write date and name and a short description of &amp;gt;&amp;gt;every&amp;lt;&amp;lt; modification/correction made after the script went into production the first time.&lt;BR /&gt;&lt;BR /&gt;6) Below the line "# RETURN VALUES", write all return values along with their meanings that can be given back by your script.&lt;BR /&gt;&lt;BR /&gt;7) Below the line "# list of subroutines:", list all subroutines/functions you're using in your script along with a very short (half line) description of the subroutine/function.&lt;BR /&gt;&lt;BR /&gt;8) Below the line "# list of important variables and their meanings:", list all important variables that are typical used as global variables along with a very short (half line) description of the variables.&lt;BR /&gt;&lt;BR /&gt;9) Do use capital letters for all the important variables.&lt;BR /&gt;&lt;BR /&gt;10) On the top of the main part of your script, set all default values to the variables you have to use. Define/initialize all the global variables on the top of the main part, even if a variable needs not to be initialized. A better solution is to put all these stuff into a separate subroutine.&lt;BR /&gt;&lt;BR /&gt;11) Define one variable, e.g. $caller, that holds the name of your script, e.g. in perl this would be&lt;BR /&gt;($CALLER,@rem) = reverse split('/',$0); undef @rem;&lt;BR /&gt;or in ksh&lt;BR /&gt;caller=${caller##*/}&lt;BR /&gt;&lt;BR /&gt;12) Explicitly, write error/warning messages into stderr, and normal information into stdout. Be strict, in doing so.&lt;BR /&gt;&lt;BR /&gt;13) Every message you are printing to stdout must be preceded by "[$CALLER]: &lt;YOUR message=""&gt;" or "ERROR [$CALLER]: &lt;YOUR message=""&gt;".&lt;BR /&gt;&lt;BR /&gt;14) Be sure, your script never reaches undefined states. Very important!&lt;BR /&gt;&lt;BR /&gt;15) In all cases when your are printing error message, be sure that even the most stupid assumed user can interprete the error message.&lt;BR /&gt;&lt;BR /&gt;16) Each error message must explain (not just tell) the error. Avoid typical Microsoft error messages, like (in german) "Allgemeine SchuSSverletzung" or "This error should never occur." or "Division by zero"!! This would be a very bad style in error handling/messaging.&lt;BR /&gt;&lt;BR /&gt;17) Use exit values. Use 0 for no errors occurred. Use a number greater than 0 if errors occurred. If possible, use different exit values for different possible error states. Use exit values, even if you today "definitely know, you would never interprete these exit values". Be sure, in the future, you'd like to do so, or one of your colleague will.&lt;BR /&gt;&lt;BR /&gt;18) Always program the option "-h" or "-?" that will print the usage of the script.&lt;BR /&gt;&lt;BR /&gt;19) Use the man page facility in Unix/Linux to document the usage of your script. While documenting, use the standard as you can see in ls(1), cp(1), man(1), and so on. (I am using self-written man pages of my own very often. Therefore, I and others do not have to look into the source code for possible options/arguments.)&lt;BR /&gt;&lt;BR /&gt;I think, I forgot many other important things. But, other forum members will help you, too.&lt;/YOUR&gt;&lt;/YOUR&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:32:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785359#M821493</guid>
      <dc:creator>Thomas Schler_1</dc:creator>
      <dc:date>2002-08-13T19:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785360#M821494</link>
      <description>Joe&lt;BR /&gt;&lt;BR /&gt;1.  Anotate your scripts.&lt;BR /&gt;2.  Use full path to system commands.&lt;BR /&gt;&lt;BR /&gt;e.g. /usr/bin/rm not just rm.&lt;BR /&gt;&lt;BR /&gt;3.  When putting a rm in a script &lt;BR /&gt;&lt;BR /&gt;WRONG&lt;BR /&gt;----------------&lt;BR /&gt;cd /usr/fred&lt;BR /&gt;/usr/bin/rm *&lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;Right &lt;BR /&gt;---------------&lt;BR /&gt;/usr/bin/rm /usr/fred/*&lt;BR /&gt;---------------&lt;BR /&gt;&lt;BR /&gt;If the cd fails then all sort of problems can occur.&lt;BR /&gt;&lt;BR /&gt;4.  Test fully each script before putting it near a live environment - we all know what a typo can do.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Just some ideas.&lt;BR /&gt;&lt;BR /&gt;Paula&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:35:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785360#M821494</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-08-13T19:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785361#M821495</link>
      <description>Joe&lt;BR /&gt;&lt;BR /&gt;Two definite DO's:&lt;BR /&gt;&lt;BR /&gt;1)Make sure you document your scripts with as much commenting as possible, this will provide an invaluable training mechanism for your junior level admins just getting started in scripting.&lt;BR /&gt;&lt;BR /&gt;2) Write shell scripts using a modular approach thus providing an easier path to following and understanding the logic.&lt;BR /&gt;&lt;BR /&gt;Just my 2.5 cents worth.&lt;BR /&gt;&lt;BR /&gt;Good luck in your book&lt;BR /&gt;&lt;BR /&gt;FG.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:35:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785361#M821495</guid>
      <dc:creator>fg_1</dc:creator>
      <dc:date>2002-08-13T19:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785362#M821496</link>
      <description>Hi Joe,&lt;BR /&gt;&lt;BR /&gt;Something to consider - who will be running the script (root/other user) and what permissions should be set on it.  If it is run by root, then it should be secured so that it can't be altered and run by another user - whether maliciously or not.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Jo</description>
      <pubDate>Tue, 13 Aug 2002 19:37:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785362#M821496</guid>
      <dc:creator>Joanne Keegan</dc:creator>
      <dc:date>2002-08-13T19:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785363#M821497</link>
      <description>I like to use a lot of functions in my script, it makes debugging and maintenance much easier and increase readability. For example ..&lt;BR /&gt;function whoareyou {&lt;BR /&gt;[[ `whoami` != root ]] &amp;amp;&amp;amp; { print "Need superuser to run this."; exit 1; }&lt;BR /&gt;}&lt;BR /&gt;The function "whoareyou" can then be called later in the main program. You can even have different programmers code different functions, it makes distribution of work much easier.&lt;BR /&gt;..just my quick $0.02&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:51:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785363#M821497</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-08-13T19:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785364#M821498</link>
      <description>For installations and upgrades: Create a detailed implemetation plan and a detailed test plan.&lt;BR /&gt;&lt;BR /&gt;The implementation plan should include a check list to be checked off as the steps in the plan are implemented. (A check, date, and initials work fine). It should also contain the actual commands that are to be used.&lt;BR /&gt;&lt;BR /&gt;If the steps in the implementation plan are incorrect, update the plan.&lt;BR /&gt;&lt;BR /&gt;Save the plan for the next install/update.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Marty &lt;WHO has="" saved="" himself="" hours="" of="" grief="" by="" following="" this="" advice=""&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/WHO&gt;</description>
      <pubDate>Tue, 13 Aug 2002 19:51:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785364#M821498</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-08-13T19:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785365#M821499</link>
      <description>- As mentioned, never use $PATH..always make your own to bypass Trojan Horses:&lt;BR /&gt;&lt;BR /&gt;export PATH=/usr/bin&lt;BR /&gt;&lt;BR /&gt;If you need commands from other directories, add them to the PATH just for this script.&lt;BR /&gt;&lt;BR /&gt;- I like the idea of handling temp files (choose /var/temp ir $TEMP or $TMPDIR is not set). However, after creating about 10 tempfiles, remembering to purge them at the end or in a trap statement became unruly. So now I create a temp directory with $$ as part of the name, then throw whatever filenames I want into that directory and at the end, just recursively remove the one temp directory:&lt;BR /&gt;&lt;BR /&gt;MYNAME=${0##*/}&lt;BR /&gt;TMPDIR="${TEMP:-/var/tmp}$MYNAME.$$"&lt;BR /&gt;&lt;BR /&gt;cp LotsOFfiles $TMPDIR&lt;BR /&gt;..do stuff..&lt;BR /&gt;trap 'eval rm -rf $TMPDIR' 0 1 2 3 15&lt;BR /&gt;&lt;BR /&gt;- And a real gem for script writers: &lt;A href="http://www.shelldorado.com" target="_blank"&gt;www.shelldorado.com&lt;/A&gt; You can spend hours looking through the ideas.</description>
      <pubDate>Tue, 13 Aug 2002 22:49:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785365#M821499</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2002-08-13T22:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785366#M821500</link>
      <description>Here is a template I use:&lt;BR /&gt;Attached is a simple document on the explanation of RCS&lt;BR /&gt;&lt;BR /&gt;################################################################################&lt;BR /&gt;# RCS Info:     $Source: $&lt;BR /&gt;#               $Revision: $&lt;BR /&gt;#               $Date: $&lt;BR /&gt;#&lt;BR /&gt;##REMOVE        This is a template for scripts.  Edit the lines tagged&lt;BR /&gt;##REMOVE        with "##REPLACE", with appropriate information, and then&lt;BR /&gt;##REMOVE        develop the rest of the script.&lt;BR /&gt;##REMOVE        Use RCS to track changes to your script.&lt;BR /&gt;##REMOVE        See also TEMPLATE.config.&lt;BR /&gt;##REMOVE        Lastly, remove these lines tagged with "##REMOVE".&lt;BR /&gt;##REMOVE&lt;BR /&gt;# Comments:&lt;BR /&gt;##REPLACE       Description of script&lt;BR /&gt;#&lt;BR /&gt;# RCS log:      $Log: $&lt;BR /&gt;# &lt;BR /&gt;################################################################################&lt;BR /&gt;#&lt;BR /&gt;# Set environment variables from the configuration file&lt;BR /&gt;#&lt;BR /&gt;. ${0}.config&lt;BR /&gt;&lt;BR /&gt;rval=0                          # set the default return value for this script&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# FUNCTIONS&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Mail_Outcome  -- mail log and exit&lt;BR /&gt;#                       To get the approriate responce from operators and/or&lt;BR /&gt;#                       Unix Sysadmins, start the subject of mail with either:&lt;BR /&gt;#                       SUCCESS:&lt;BR /&gt;#                       INFORMN:&lt;BR /&gt;#                       WARNING:&lt;BR /&gt;#                       FAILURE:&lt;BR /&gt;#&lt;BR /&gt;Mail_Outcome()&lt;BR /&gt;{&lt;BR /&gt;if [ $rval -eq 0 ]; then&lt;BR /&gt;  mailx -s "SUCCESS: $(basename $0)" $MAIL_TO_SUCCESS &amp;lt; $LOGFILE&lt;BR /&gt;else&lt;BR /&gt;  mailx -s "FAILURE: $(basename $0)" $MAIL_TO_FAILURE &amp;lt; $LOGFILE&lt;BR /&gt;fi&lt;BR /&gt;exit $rval&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Set_Return    -- Check the exit value of a command run by this script&lt;BR /&gt;#&lt;BR /&gt;Set_Return()&lt;BR /&gt;{ &lt;BR /&gt;        # Check the exit value of a command run by this script.  The exit code&lt;BR /&gt;        # is echoed to the log file and if non-zero, the return value of this&lt;BR /&gt;        # script is set to indicate failure. &lt;BR /&gt;        return=$?   &lt;BR /&gt;        if [ $return -eq 0 ]&lt;BR /&gt;        then echo "done (rc=$return)\n"&lt;BR /&gt;        else&lt;BR /&gt;                echo "ERROR (rc=$return)\n"&lt;BR /&gt;                rval=1  # script had an error&lt;BR /&gt;        fi &lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Start_logging -- Open logfile and output "header" information.&lt;BR /&gt;#&lt;BR /&gt;Start_Logging ()&lt;BR /&gt;{&lt;BR /&gt;exec &amp;gt;$LOGFILE 2&amp;gt;&amp;amp;1             # Log change output from this script&lt;BR /&gt;echo $SEP1&lt;BR /&gt;echo "$(date) Starting $DESCRIPTION"&lt;BR /&gt;echo '$Source: $'&lt;BR /&gt;echo '$Revision: $'&lt;BR /&gt;echo "Script ${0} being run on host $(uname -n)"&lt;BR /&gt;echo '# '&lt;BR /&gt;echo '# KEY PARAMETERS'&lt;BR /&gt;echo '# --------------'&lt;BR /&gt;echo '# '&lt;BR /&gt;echo '# Logging Parameters'&lt;BR /&gt;echo "# LOGFILE: $LOGFILE"&lt;BR /&gt;echo '# '&lt;BR /&gt;##REPLACE       Other key paramaters&lt;BR /&gt;echo ''&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Stop_Logging  -- Finish off log and mail notification&lt;BR /&gt;#&lt;BR /&gt;Stop_Logging()&lt;BR /&gt;{&lt;BR /&gt;echo ""&lt;BR /&gt;echo "$(date) Finished $DESCRIPTION"&lt;BR /&gt;echo $SEP1&lt;BR /&gt;Mail_Outcome&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Usage         -- displays the usage message and exits.&lt;BR /&gt;#&lt;BR /&gt;Usage()&lt;BR /&gt;{&lt;BR /&gt;  printf "\nUsage: %s \n" `basename $0`&lt;BR /&gt;  exit 1&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# MAIN PROGRAM&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;##REPLACE       Any set up stuff such as parsing paramaters.&lt;BR /&gt;&lt;BR /&gt;Start_Logging&lt;BR /&gt;&lt;BR /&gt;##REPLACE       The guts of the script!&lt;BR /&gt;&lt;BR /&gt;Stop_Logging&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 23:09:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785366#M821500</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2002-08-13T23:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785367#M821501</link>
      <description>Think portable. At the moment you might be working with HP-UX, but there will be a time that you are faced with AIX problems, or Solaris, or Linux, or ...&lt;BR /&gt;&lt;BR /&gt;Do not use Vendor specific extensions to whatever utility - not even for the shell.&lt;BR /&gt;&lt;BR /&gt;If you *do* need specific features for utilities (like +2Gb for tar) use only utilities that are freely available (GNU tar) and not vendor specific alterations that cannot be found on other systems.&lt;BR /&gt;&lt;BR /&gt;Only script in scripting languages that are available on most systems, not on some&lt;BR /&gt;&lt;BR /&gt;+ sh&lt;BR /&gt;+ ksh&lt;BR /&gt;+ csh&lt;BR /&gt;+ sed&lt;BR /&gt;+ awk&lt;BR /&gt;+ perl&lt;BR /&gt;&lt;BR /&gt;- tcsh&lt;BR /&gt;- bash&lt;BR /&gt;- python&lt;BR /&gt;- tcl&lt;BR /&gt;- visual basic&lt;BR /&gt;- ruby&lt;BR /&gt;&lt;BR /&gt;And as others have stated: Use comments, especially about what your prerequisitions, environment and other expected (and unexpected) side effects</description>
      <pubDate>Wed, 14 Aug 2002 05:41:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785367#M821501</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-08-14T05:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Developer Guide - Please post your Tips.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785368#M821502</link>
      <description>1. Strange as it sounds, DON'T alias "rm" to "rm -i". I used to do this earlier, and I always expected a "rm" to ask if I'm sure. Till I got onto a production machine where the alias wasn't set, and the rest, as they say, is history :-)&lt;BR /&gt;&lt;BR /&gt;2. To debug scripts, just stick in a "set -x". No need to "echo" anything!&lt;BR /&gt;&lt;BR /&gt;3. Specify your shell on the first line of a script like so "#!/usr/bin/ksh". Scripts written to work with ksh wont work well with csh and vice versa.&lt;BR /&gt;&lt;BR /&gt;4. If you're mucking around with terminal settings and your cursor disappears, dont panic. A "stty sane" should fix it. &lt;BR /&gt;&lt;BR /&gt;5. To test a script that you're editing without having to exit from the vi screen, just do a "&lt;ESCAPE&gt;:!sh %"&lt;BR /&gt;&lt;BR /&gt;6. Learn Perl! A look at some of the recent repsonses on this forum will show you that Perl is quicker, cleaner and more elegant than equivalent shell scripts. (I gotta do this myself, someday.)&lt;/ESCAPE&gt;</description>
      <pubDate>Wed, 14 Aug 2002 07:04:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-developer-guide-please-post-your-tips/m-p/2785368#M821502</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-08-14T07:04:52Z</dc:date>
    </item>
  </channel>
</rss>

