Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The location, availability, and versions of some of these tools is precisely why cross-platform shell scripting is so tricky. Also, as perigeeV observes, a big factor in the emergence of Perl as a cross OS tool. Most of the tools you describe are standard UNIX commands and are likely to be found in /bin or /usr/bin. Both should be in your path with a standard shell login on most UNIX systems. echo is likely to be found as a shell built-in.

You are correct about "which" only working within your path. However, for most of these, that would be a safe assumption. sqlplus and gtar are more problematic, as they may not be installed on your target system at all, or might be found other places (like /usr/local/bin). The only sure way to know is to check for yourself before-hand (assuming shell access) or ask your sys admin. Shell could be any number of varieties from Bourne to Korn to Bash to POSIX to...so YMMV regarding aliases and built-ins. Again, your sys admin is the definitive source.

awk might be one of the most troublesome as there are significant differences in versions and it is not uncommon to have multiple versions on the same system (awk, gawk, nawk...). One of our systems had both awk and nawk and each was referenced by a symlink named awk at different places. Made for real interesting behavior if you had a dot in your path!

I second the notion of using a pure perl solutions where possible. Do you need echo when you have print, printf, and formats? Do you need grep when you have, arguably, more powerful regex capabilities within Perl? Most(all?) of what you listed has a pure Perl counterpart.

You might also want to take a look at Heiner's SHELLdorado. It is an excellent refernece for shell tools that includes info and or links covering awk version compatibility and cross-platform shell scripting.


In reply to Re: External Dependencies on Unix Commands by rah
in thread External Dependencies on Unix Commands by hackdaddy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found