- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Unix Developer Guide - Please post your Tips.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2002 10:01 AM
11-18-2002 10:01 AM
Re: Unix Developer Guide - Please post your Tips.
here are my suggestions (though I'm not sure if I'm in a position to suggest or even advise)
Do use shell scripts only for small scripts.
Sooner or later you will end up in copying and pasting.
Instead use a programming language which is highly modularizable and makes up for rapid development (or prototyping).
The ideal language, especially in a Unix environment, to me seems to be Perl (but Python is also neat, maybe it forces you to write more readable code;-)
If you use Perl,
DON'T REINVENT THE WHEEL!
always check here first:
http://www.cpan.org/
chances are someone came up with a nice module already that exactly fits your problem.
Then the usual Perl advice,
get into the habit to use these pragmas in your scripts:
use warnings;
use strict;
If you code for an untrustworthy environment (e.g. CGI, setuid etc.) activate Perl's taint checking -T
As so much was posted with regard to temporary files, if you really need those (I think you hardly ever need them in Perl as you can build up fancy data structures) instead of making up a filename with your PID $$ rather use
IO::File->new_tmpfile()
Always check if opening of files, pipes, sockets has been successful (e.g. die idiom) before attempting to read/write.
When there are chances for race conditions use locking
e.g.
use Fcntl ':flock';
Use shell escapes as rarely as possible
(these are those notoriuos qx, `...`, open FH, "$cmdstr |", system/exec $single_cmdstr)
Instead use Perl built-ins (or CPAN modules).
They are safer and quicker.
Also try to avoid globbing.
Avoid the shell by invoking exec/system with a list of args rather than a single string (see: perldoc -f exec)
Document your code through POD.
It is easy to learn.
Put reusable code in a module.
Share your code and submit your modules to CPAN.
Discover the wealth of POD that already was installed on your system,
start with
perldoc perl
Regards
Ralph
p.s. sorry for the Perl bias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2002 09:15 AM
12-17-2002 09:15 AM
Re: Unix Developer Guide - Please post your Tips.
Thanks for all the inputs to the guide. It was very useful. Any Gurus who might have not posted to the guide, here is another chance to share your expertise. Thanks once gain. This is a great forum.
Thanks
Joe.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2002 09:30 AM
12-17-2002 09:30 AM
Re: Unix Developer Guide - Please post your Tips.
I think all is said.
Here I post a link I found time ago and I think its important.
http://www.shelldorado.com/goodcoding/cmdargs.html
Regards, Vicente.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2002 12:00 PM
12-17-2002 12:00 PM
Re: Unix Developer Guide - Please post your Tips.
/tmp/tarif/member
/tmp/user1
/home/tarif
failed
/usr/share
/var/tmp
failed
...
-The following script will extract only lines that are followed by failed keyword :
# for i in `awk '$0 == "failed" {print NR}' afile`
> do
> (( x = $i - 1 ))
> awk 'NR == '$x' {print}' afile
> done
the output of the script will return:
/home/tarif
/var/tmp
Cheers,
T??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2002 01:16 PM
12-17-2002 01:16 PM
Re: Unix Developer Guide - Please post your Tips.
The worst thing our applications guys do to us is make their apps run in a 'debug' or 'verbose' mode in development, and then forget to turn it off when moving to production. Where possible, if you must log, make the messages that come be brief, too the point, and necessary. Lots of times, there really is not a need to log every single step of a process, every time.
Also, make error messages inituative. My favorite error the goes against this rule is 'Access Denied'
Hope it helps.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2002 08:55 AM
12-18-2002 08:55 AM
Re: Unix Developer Guide - Please post your Tips.
Thanks
Joe.
- « Previous
-
- 1
- 2
- Next »