Home > Archive > PERL Beginners > June 2005 > host id
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Bret Goodfellow 2005-06-09, 8:55 pm |
| Simple question to answer, I hope. I am running on an HP-UX system, and
would like to retrive the UNIX system's host-id (name of box). Is there
a function to do this?
| |
| John W. Krahn 2005-06-09, 8:55 pm |
| Bret Goodfellow wrote:
> Simple question to answer, I hope. I am running on an HP-UX system, and
> would like to retrive the UNIX system's host-id (name of box). Is there
> a function to do this?
This may be what you want:
perldoc Sys::Hostname
John
--
use Perl;
program
fulfillment
| |
| Brian Barto 2005-06-09, 8:56 pm |
| I, being too lazy to look up a perl function, would use hostname command in
backticks like so:
$HostID = `hostname`;
Not sure if that will catch a newline character so I would also follow it
with this:
$HostID =~ s/\n//;
-----Original Message-----
From: Bret Goodfellow [mailto:Bret.Goodfellow@questar.com]
Sent: Thursday, June 09, 2005 3:36 PM
To: beginners@perl.org
Subject: host id
Simple question to answer, I hope. I am running on an HP-UX system, and
would like to retrive the UNIX system's host-id (name of box). Is there
a function to do this?
| |
| Wiggins d'Anconia 2005-06-09, 8:56 pm |
| "Because it's up-side down.
Why is that?
It makes replies harder to read.
Why not?
Please don't top-post." - Sherm Pendley, Mac OS X list
brian.barto@spectrum-health.org wrote:
> I, being too lazy to look up a perl function, would use hostname command in
> backticks like so:
>
> $HostID = `hostname`;
>
Right which is why the above is "too lazy". Anyone reading this please
don't settle for the above, it is error prone, insecure, and
insufficient. There is no error checking, there at least needs to be a
full path, and it is potentially slower.
> Not sure if that will catch a newline character so I would also follow it
> with this:
>
> $HostID =~ s/\n//;
Right, in which case we can at least suggest 'chomp',
perldoc -f chomp
http://danconia.org
>
> -----Original Message-----
> From: Bret Goodfellow [mailto:Bret.Goodfellow@questar.com]
> Sent: Thursday, June 09, 2005 3:36 PM
> To: beginners@perl.org
> Subject: host id
>
>
> Simple question to answer, I hope. I am running on an HP-UX system, and
> would like to retrive the UNIX system's host-id (name of box). Is there
> a function to do this?
>
>
| |
| Ryan Frantz 2005-06-09, 8:56 pm |
| Sure, don't top-post. But then who's gonna bother to scroll to the end
of the email as the thread gets longer? Many users don't even realize
that there is a reply in bottom-posted emails. Bottom-posting ignores
the natural behavior of most users.
Another example of human behavior (top vs. bottom):
Q: Where's the first place your eyes take you when you visit a web page?
A: The upper left quadrant of the page. Not the bottom.
As an added note, just get over it. It's nothing to sweat.
ry
-----Original Message-----
From: Wiggins d'Anconia [mailto:wiggins@danconia.org]=20
Sent: Thursday, June 09, 2005 4:02 PM
To: brian.barto@spectrum-health.org
Cc: Bret.Goodfellow@questar.com; beginners@perl.org
Subject: Re: host id
"Because it's up-side down.
Why is that?
It makes replies harder to read.
Why not?
Please don't top-post." - Sherm Pendley, Mac OS X list
brian.barto@spectrum-health.org wrote:
> I, being too lazy to look up a perl function, would use hostname
command in
> backticks like so:
>=20
> $HostID =3D `hostname`;
>=20
Right which is why the above is "too lazy". Anyone reading this please
don't settle for the above, it is error prone, insecure, and
insufficient. There is no error checking, there at least needs to be a
full path, and it is potentially slower.
> Not sure if that will catch a newline character so I would also follow
it
> with this:
>=20
> $HostID =3D~ s/\n//;
Right, in which case we can at least suggest 'chomp',
perldoc -f chomp
http://danconia.org
>=20
> -----Original Message-----
> From: Bret Goodfellow [mailto:Bret.Goodfellow@questar.com]
> Sent: Thursday, June 09, 2005 3:36 PM
> To: beginners@perl.org
> Subject: host id
>=20
>=20
> Simple question to answer, I hope. I am running on an HP-UX system,
and
> would like to retrive the UNIX system's host-id (name of box). Is
there
> a function to do this?
>=20
>=20
--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
| |
| Chris Devers 2005-06-09, 8:56 pm |
| On Thu, 9 Jun 2005, Ryan Frantz wrote:
> Sure, don't top-post. But then who's gonna bother to scroll to the
> end of the email as the thread gets longer?
Polite people trim their replies to avoid this problem.
> Many users don't even realize that there is a reply in bottom-posted
> emails.
Broken mail agents are not the rest of the world's problem :-)
> Bottom-posting ignores the natural behavior of most users.
Broken habits are also not our problem to fix :-)
"When in Rome, do as the Romans do." It's true all over. The polite
thing to do when participating in *any* group -- not just this one, not
just internet stuff, but any human interaction -- is to adapt your
manner of presenting yourself to be in harmony with the group.
If you notice the archives of this list, like many other lists, most of
the people -- and nearly all of the "veterans" -- quote inline, and
don't top-post. If you lost track of a discussion, there are
easy-to-find archives on the web that can help orient you.
(Not that chastizing people is polite either, but too late for that now.
Sorry, I'll leave it be with this one message.)
--
Chris Devers
| |
| Brian Barto 2005-06-09, 8:56 pm |
| >
> "When in Rome, do as the Romans do." It's true all over. The polite
> thing to do when participating in *any* group -- not just
> this one, not
> just internet stuff, but any human interaction -- is to adapt your
> manner of presenting yourself to be in harmony with the group.
>
> If you notice the archives of this list, like many other
> lists, most of
> the people -- and nearly all of the "veterans" -- quote inline, and
> don't top-post. If you lost track of a discussion, there are
> easy-to-find archives on the web that can help orient you.
>
> (Not that chastizing people is polite either, but too late
> for that now.
> Sorry, I'll leave it be with this one message.)
>
Thank you for a constructive reply. I changed a setting in my outlook client
to prefix the original message after I read this. Prior to this I though it
was just silliness but now I understand that replying inline makes archives
easier to read.
- Brian
| |
| Brian Barto 2005-06-09, 8:56 pm |
|
> hostname command in
>
> Right which is why the above is "too lazy". Anyone reading this please
> don't settle for the above, it is error prone, insecure, and
> insufficient. There is no error checking, there at least needs to be a
> full path, and it is potentially slower.
After the initial shock of having 1 simple assignment statement ripped to
shreds, I thought about it for a minute and it downed on me that I'm not
buying into your accusations. I would like you to please explain them. If
these are indeed realistic problems then everyone should know why. And
please don't use examples like, "it is insecure because someone could swap
out the hostname binary with something potentially damaging" because that
would require root access and for that matter a bang statement to the perl
binary would suffer from the same security flaws.
> also follow it
>
> Right, in which case we can at least suggest 'chomp',
Matter of preference really. I like using regex.
> system, and
> box). Is there
>
| |
| Wiggins d'Anconia 2005-06-09, 8:56 pm |
| brian.barto@spectrum-health.org wrote:
>
>
> After the initial shock of having 1 simple assignment statement ripped to
> shreds, I thought about it for a minute and it downed on me that I'm not
> buying into your accusations. I would like you to please explain them. If
> these are indeed realistic problems then everyone should know why. And
> please don't use examples like, "it is insecure because someone could swap
> out the hostname binary with something potentially damaging" because that
> would require root access and for that matter a bang statement to the perl
> binary would suffer from the same security flaws.
>
Very well.....
1. Insecure: when using a shell command from a script you are at the
mercy of the environment of the invoking user. If you do not have
complete control of the environment you are at risk. This was the oldest
trick in the book when I was in college, create a script called 'su',
place it in a 'bin' directory in your user account, place '~/bin' at the
front of the PATH environment variable. Then go to the sy mins and say
you had screwed up your account in some manner that would require them
to become root. So logged in under your user they ran 'su' which was
naturally setup to emulate the look of the real 'su' command. After
about 10 seconds you now have root's password. Of course most people
aren't this susceptible anymore, and most are using 'sudo' which has
protections in place, but the point remains. Unless you use a full path
to a script you have no idea of what malicious intent has been placed in
the path to cause you problems. And even if you do use a full path there
is nothing to say that the command you are calling hasn't been replaced.
Not to mention any code receiving input from an external source should
have taint checking on. (Despite your claim to the contrary this is
still a real enough threat.)
2. Error Prone: your command is insufficent because you do not check
whether or not the command was even runnable. Backticks provides a
return result in $? that will tell you whether or not you were able to
fork, and whether or not the command existed, you had the proper
permissions, etc. Without checking all of this each time you call out to
a system command you are not providing sufficient error checking. On top
of that you were not checking the exit value of the command so you don't
know if it ran successfully or not, you only know whether you got any
output. You don't know if it dumped core, or what signal caused it to
stop in the case that it failed. You also didn't include the STDERR
capturing idiom in the command so you don't know if there was error
output or warnings generated.
3. Portability: the command issued may have different switches, may not
exist, or may be for a completely different purpose depending on what
platform you are running. 'hostname' is actually the perfect example,
because to my knowledge it doesn't even exist on Windows systems. Many
commands have very different settings and interfaces across the many
unix systems, and depending on the available /bin/sh (assuming it is the
default system shell, which isn't necessarily true either) there may be
different quoting patterns needed, or the shell may not support long
option processing. Granted a lot of code is intended to run on a single
platform, but unless that was specifically provided in the spec by the
poster you don't know, so can't assume. Some systems may not even
provide a proper fork clone, more on that below.
4. Speed/Forking: because backticks causes a fork, you are using system
resources in a way you wouldn't necessarily need to if you were able to
use a built-in function. When Perl forks, it forks an exact copy of the
running process and then transitions to the new command (at least on
*nix systems) which may cause use of memory resources, file descriptors
(which include open sockets to databases or possible remote locations),
and other system level attributes that you wouldn't otherwise need. And
the memory footprint of the running process includes all loaded modules
so could be quite large. When running a forked system command, the perl
interpreter has to fork, then exec the shell, the shell then has to
parse the command line (which unless you have seen the parsing map you
wouldn't believe how long this takes), then it has to fork and exec
again into the running process, that process may then have to do its own
option parsing, etc. which all could have been avoided by using the
internal method. So it is almost always slower to call a system command
when an internal method is available. Finally each call to
system/backticks is independent, meaning that depending on the command
being run and the optimizations of the alternatives there is no
potential to use caching, session management, etc. to improve
efficiency. Although system/backticks are written correctly in Perl 5,
if you are using your own fork/exec model and don't include sufficient
'wait' code then your system may also become swamped by zombies,
eventually causing a locked system, assuming you don't hit the memory
limit first.
I leave it to you whether I have backed up my position, but shelling out
should *always* be an absolute last resort, which at times does happen,
but when it does it should be executed with care and diligence. And if a
module exists that can provide an alternative it should definitely be
used, if for no other reason than maybe it will have to shell out too,
but in that case the module author has more likely thought of the above
things and done his best to avoid the issue. Sys::Hostname is the
perfect example, it will eventually shell out too if all the preferred
methods fail, but it does the proper amount of error checking, taint
checking, etc. Check out the source if you want to see what I mean by
sufficient handling.
http://search.cpan.org/src/NWCLARK/...ame/Hostname.pm
And those are just my reasons, the gurus may have more/better ones...
>
>
>
> Matter of preference really. I like using regex.
>
Well again if your preference is error proneness and slower by all
means, I can't prevent you from doing it. But you haven't considered
what the new line character may be for the given system, whether or not
the given shell/program provides one. And firing up the regex engine
will always be slower than using a simple chomp, especially since you
are making the assumption that there is only one new line (fairly safe
granted with 'hostname') and haven't even provided the courtesy of
anchoring it to the end of the string to at least get that efficiency
improvement.
It is still just sloppiness, and beginners don't need to be picking up
bad habits.
http://danconia.org
[snip]
| |
| DBSMITH@OhioHealth.com 2005-06-10, 8:55 pm |
| I whole heartedly agree!
top post rules!
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
"Ryan Frantz"
<RyanFrantz@infor
med-llc.com> To
"Wiggins d'Anconia"
06/09/2005 04:13 <wiggins@danconia.org>,
PM <brian.barto@spectrum-health.org>
cc
<Bret.Goodfellow@questar.com>,
<beginners@perl.org>
Subject
RE: host id
Sure, don't top-post. But then who's gonna bother to scroll to the end
of the email as the thread gets longer? Many users don't even realize
that there is a reply in bottom-posted emails. Bottom-posting ignores
the natural behavior of most users.
Another example of human behavior (top vs. bottom):
Q: Where's the first place your eyes take you when you visit a web page?
A: The upper left quadrant of the page. Not the bottom.
As an added note, just get over it. It's nothing to sweat.
ry
-----Original Message-----
From: Wiggins d'Anconia [mailto:wiggins@danconia.org]
Sent: Thursday, June 09, 2005 4:02 PM
To: brian.barto@spectrum-health.org
Cc: Bret.Goodfellow@questar.com; beginners@perl.org
Subject: Re: host id
"Because it's up-side down.
Why is that?
It makes replies harder to read.
Why not?
Please don't top-post." - Sherm Pendley, Mac OS X list
brian.barto@spectrum-health.org wrote:
> I, being too lazy to look up a perl function, would use hostname
command in
> backticks like so:
>
> $HostID = `hostname`;
>
Right which is why the above is "too lazy". Anyone reading this please
don't settle for the above, it is error prone, insecure, and
insufficient. There is no error checking, there at least needs to be a
full path, and it is potentially slower.
> Not sure if that will catch a newline character so I would also follow
it
> with this:
>
> $HostID =~ s/\n//;
Right, in which case we can at least suggest 'chomp',
perldoc -f chomp
http://danconia.org
>
> -----Original Message-----
> From: Bret Goodfellow [mailto:Bret.Goodfellow@questar.com]
> Sent: Thursday, June 09, 2005 3:36 PM
> To: beginners@perl.org
> Subject: host id
>
>
> Simple question to answer, I hope. I am running on an HP-UX system,
and
> would like to retrive the UNIX system's host-id (name of box). Is
there
> a function to do this?
>
>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
| |
| Thomas Bätzler 2005-06-10, 8:55 pm |
| DBSMITH@OhioHealth.com <DBSMITH@OhioHealth.com> wrote:
> I whole heartedly agree!
>
> top post rules!
well, it certainly doesn't require the poster to spend much
thought on his post. Hit reply, press some keys, done.
Readability be damned, and who cares about bandwidth and
storage anymore?
Probably "Ryan Frantz" <RyanFrantz@informed-llc.com> wrote:
[note how I can't tell who wrote what?]
> Sure, don't top-post. But then who's gonna bother to scroll
> to the end of the email as the thread gets longer? Many
You don't have to. Intelligent posters quote what they need,
editing out the superfluous stuff. Note how the comments go
close to the quoted material?
> users don't even realize that there is a reply in
> bottom-posted emails.
"Look, that idiot send me a quote-only mail again". Yeah, right.
> Bottom-posting ignores the natural
> behavior of most users.
And they'd probably still pee in the corners if they hadn't
been housebroken by their parents ;-)
> As an added note, just get over it. It's nothing to sweat.
Actually, in my book it's a show of rudeness. By top posting
you clearly place your own comfort over that of your readers.
Cheers,
Thomas
| |
| Ryan Frantz 2005-06-10, 8:55 pm |
|
> You don't have to. Intelligent posters quote what they need,
> editing out the superfluous stuff. Note how the comments go
> close to the quoted material?
>=20
I'll take that one on the chin. ;)
>=20
> "Look, that idiot send me a quote-only mail again". Yeah, right.
>=20
>=20
> And they'd probably still pee in the corners if they hadn't
> been housebroken by their parents ;-)
>=20
>=20
> Actually, in my book it's a show of rudeness. By top posting
> you clearly place your own comfort over that of your readers.
>=20
I wouldn't go so far as to say it's rude; perhaps not preferred, but not
necessarily rude. In the spirit of compromise let's say this:
Insofar as normal email habits go, top-posting won't go away. Remember,
in many cases doing anything sometimes requires doing so for the least
common denominator (i.e. (untrained|unaware|stupid|rude) end users
top-posting, coding web content for older browsers etc.)
For the purposes of this list, I shall always post intelligently as has
been stated (tactfully by some, tersely by others) to avoid any
confusion and/or discomfort for my fellow posters. For continuity, I
would suggest everyone does the same.
I humbly submit this response sans sarcasm.
ry
| |
| Bob Showalter 2005-06-10, 8:55 pm |
| Ryan Frantz wrote:
> For the purposes of this list, I shall always post intelligently as
> has been stated ... For continuity, I
> would suggest everyone does the same.
Excellent suggestion.
For those who would like to post replies in the preferred "conversational"
style or "inline" style (or whatever you want to call it) using Outlook or
Outlook Express, a quick google for "outlook quotefix" or "oe quotefix" will
turn up some wonderful little tools to make such posts a breeze.
| |
| Brian Barto 2005-06-10, 8:55 pm |
| > Ryan Frantz wrote:
>
> Excellent suggestion.
>
> For those who would like to post replies in the preferred
> "conversational"
> style or "inline" style (or whatever you want to call it)
> using Outlook or
> Outlook Express, a quick google for "outlook quotefix" or "oe
> quotefix" will
> turn up some wonderful little tools to make such posts a breeze.
For outlook it's Tools/Options/Email Options/"When replying to an email
message"
Choose "Prefix each line of the original message"
It probably should be noted that I'm using outlook 2000. (Until microsoft
stops granting licenses for 2000 and forces us to shell out more money for
the upgrade :)
| |
| Bob Showalter 2005-06-10, 8:55 pm |
| brian.barto@spectrum-health.org wrote:[color=darkred]
Spot the flaw.
Please get Outlook-QuoteFix.
| |
| DBSMITH@OhioHealth.com 2005-06-10, 8:55 pm |
|
brian.barto@spect
rum-health.org
To
06/10/2005 10:55 beginners@perl.org
AM cc
Subject
RE: host id
> Ryan Frantz wrote:
>
> Excellent suggestion.
>
> For those who would like to post replies in the preferred
> "conversational"
> style or "inline" style (or whatever you want to call it)
> using Outlook or
> Outlook Express, a quick google for "outlook quotefix" or "oe
> quotefix" will
> turn up some wonderful little tools to make such posts a breeze.
For outlook it's Tools/Options/Email Options/"When replying to an email
message"
Choose "Prefix each line of the original message"
It probably should be noted that I'm using outlook 2000. (Until microsoft
stops granting licenses for 2000 and forces us to shell out more money for
the upgrade :)
Any suggestions for Lotus Notes?
derek
| |
| Jeff 'japhy' Pinyan 2005-06-10, 8:55 pm |
| On Jun 10, DBSMITH@OhioHealth.com said:
> Any suggestions for Lotus Notes?
Eww. Don't use Lotus?
Seriously though, in your reply, because of the way Lotus Notes formats
the email, there's no way of easily detecting (in my email program, PINE)
where the old text ends and your reply begins.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
| |
| Charles K. Clarkson 2005-06-10, 8:55 pm |
| DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:
:
: Any suggestions for Lotus Notes?
Use a separate text editor to phrase replies. I often do this
with Outlook with any but the most trivial response. My editor
has macros and other features which are too difficult to do in
Outlook.
Copy your quoted message from Notes to your editor and add
your reply. When finished, use the editor to convert tabs to
spaces and copy the reply back to Notes.
I use my program editor for replies to make testing snips of
code easier. If I am in the middle of a reply and need to attend
to other business, I store the incomplete reply in a draft copy in
Outlook. That way I don't have a lot of open, unfinished replies
in my editor.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
| |
| Chris Devers 2005-06-10, 8:55 pm |
| On Fri, 10 Jun 2005 DBSMITH@OhioHealth.com wrote:
> Any suggestions for Lotus Notes?
Short of "don't use Notes for mailing lists; sign up for them using a
webmail or other personal mail accout" ... no, not really.
Outlook has some broken defaults, but it's at least fixable.
Notes is just plain broken.
--
Chris Devers
hopes never to have a job that forces Notes on him ever again
foul evil stridently broken excrement of an excuse for a mail client
| |
| John Doe 2005-06-10, 8:55 pm |
| Sorry for the inline answer and my bad english.
DBSMITH@OhioHealth.com am Freitag, 10. Juni 2005 15.14:
> I whole heartedly agree!
(In this top posting manner, the sense of above sentence (at least for me) is:
Somebody agrees, and does that _whole_heartedly_. Ok, it may be interesting
sometimes to know if somebody agrees with verve and not just simply, but not
in a perl mailing list).
With what?
> top post rules!
Oh! Let's have a look:
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
>
>
>
> "Ryan Frantz"
> <RyanFrantz@infor
> med-llc.com> To
> "Wiggins d'Anconia"
> 06/09/2005 04:13 <wiggins@danconia.org>,
> PM <brian.barto@spectrum-health.org>
> cc
> <Bret.Goodfellow@questar.com>,
> <beginners@perl.org>
> Subject
> RE: host id
Derek B. Smith, Ryan Frantz, Wiggins d'Anconia and Bret.Goodfellow seem to
diskuss something.
But what?
>
[snipped 8 empty lines]
>
This? Or is this just a conveniance because of the surrounding chaos?
> Sure, don't top-post.
Pardon?
A: "top post rules!"
B: "Sure, don't top-post"
> But then who's gonna bother to scroll to the end
> of the email as the thread gets longer?
And who's gonna bother to turn over the pages in a book whose read text gets
longer and longer?
> Many users don't even realize that there is a reply in bottom-posted emails.
Huh? Why should somebody get an answer mail without an answer inside (apart
from RE:AnotherSpam?
> Bottom-posting ignores the natural behavior of most users.
Because most users switch their natural behavior when they switch from talking
to writing?
> Another example of human behavior (top vs. bottom):
>
> Q: Where's the first place your eyes take you when you visit a web page?
> A: The upper left quadrant of the page. Not the bottom.
I'd say that the focussing of the first glance is appropriate for PR stuff,
selling papers, etc.
For an intellectual (and hopefully intelligent) discussion consisting of
arguments, argument chains, explanations and tries to understand, it's
certainly not useful. This holds even more if several people take part of the
discussion.
I think there is a difference between "natural" and "widespread".
[...]
So, the thing getting agreement must follow soon!
> -----Original Message-----
> From: Wiggins d'Anconia [mailto:wiggins@danconia.org]
> Sent: Thursday, June 09, 2005 4:02 PM
> To: brian.barto@spectrum-health.org
> Cc: Bret.Goodfellow@questar.com; beginners@perl.org
> Subject: Re: host id
Interesting, indeed.
> "Because it's up-side down.
> Why is that?
> It makes replies harder to read.
> Why not?
> Please don't top-post." - Sherm Pendley, Mac OS X list
>
> brian.barto@spectrum-health.org wrote:
>
> command in
>
>
> Right which is why the above is "too lazy". Anyone reading this please
> don't settle for the above, it is error prone, insecure, and
> insufficient. There is no error checking, there at least needs to be a
> full path, and it is potentially slower.
>
>
> it
>
>
> Right, in which case we can at least suggest 'chomp',
>
> perldoc -f chomp
>
> http://danconia.org
>
>
> and
>
>
> there
>
A: "Simple question to answer, I hope. I am running on an HP-UX system,"
B: "and"
A: "would like to retrive the UNIX system's host-id (name of box). Is"
B: "there"
A: "a function to do this?"
Must be gurus. Don't understand anything.
[color=darkred]
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
very useful citation...
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
....otherwise it would not be mentioned twice.
Now, imagine my reply as top posting.
I know it's difficult to convince people to reply inline. A lot of my
customers even don't get it if their top post replies are so unclear that I
have to write another mail to ask what they meant. Even after tens of chaotic
discussions leading to misunderstandings they don't get it. They seem to
think that it is "natural" that discussions per email are chaotic.
Aaarrggghhh!
joe
| |
| DBSMITH@OhioHealth.com 2005-06-10, 8:55 pm |
| yeah thanks... company email system... Argggg... notes is evil.
for that fact IBM is evil!
Dave Gray
<yargevad@gmail.c
om> To
beginners@perl.org
06/10/2005 02:31 cc
PM
Subject
Re: host id
Please respond to
Dave Gray
<yargevad@gmail.c
om>
On 6/10/05, DBSMITH@ohiohealth.com <DBSMITH@ohiohealth.com> wrote:
> I whole heartedly agree!
>
> top post rules!
Apparently, so does Lotus Notes. My deepest sympathies.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
| |
| Dave Gray 2005-06-10, 8:55 pm |
| On 6/10/05, DBSMITH@ohiohealth.com <DBSMITH@ohiohealth.com> wrote:
> I whole heartedly agree!
>=20
> top post rules!
Apparently, so does Lotus Notes. My deepest sympathies.
| |
| Dave Gray 2005-06-10, 8:55 pm |
| On 6/9/05, Wiggins d'Anconia <wiggins@danconia.org> wrote:
> 4. Speed/Forking: because backticks causes a fork, you are using system
> resources in a way you wouldn't necessarily need to if you were able to
> use a built-in function. When Perl forks, it forks an exact copy of the
> running process and then transitions to the new command (at least on
> *nix systems) which may cause use of memory resources, file descriptors
> (which include open sockets to databases or possible remote locations),
> and other system level attributes that you wouldn't otherwise need. And
> the memory footprint of the running process includes all loaded modules
> so could be quite large. When running a forked system command, the perl
> interpreter has to fork, then exec the shell, the shell then has to
> parse the command line (which unless you have seen the parsing map you
> wouldn't believe how long this takes), then it has to fork and exec
> again into the running process, that process may then have to do its own
> option parsing, etc. which all could have been avoided by using the
> internal method. So it is almost always slower to call a system command
> when an internal method is available. Finally each call to
> system/backticks is independent, meaning that depending on the command
> being run and the optimizations of the alternatives there is no
> potential to use caching, session management, etc. to improve
> efficiency. Although system/backticks are written correctly in Perl 5,
> if you are using your own fork/exec model and don't include sufficient
> 'wait' code then your system may also become swamped by zombies,
> eventually causing a locked system, assuming you don't hit the memory
> limit first.
You (well, I) learn something new every day. That's kind of funny,
actually, (to me) that backticks load all the modules in use again
just to run hostname.
| |
| Wiggins d'Anconia 2005-06-10, 8:55 pm |
| Dave Gray wrote:
> On 6/9/05, Wiggins d'Anconia <wiggins@danconia.org> wrote:
>
>
>
> You (well, I) learn something new every day. That's kind of funny,
> actually, (to me) that backticks load all the modules in use again
> just to run hostname.
>
Ah, but that is actually the good part, it doesn't re-load the modules
(at least on most modern *nix systems). Meaning it doesn't have to
reparse, etc. it actually does a direct memory copy which makes
fork/exec very fast when you want to do something similar, the problem
only happens when you have a large process that forks to a small one and
you run into memory consumption issues. And this may or may not be the
case for the system/backtick internals, but it is for normal Perl forks
so I assumed that it was for those as well, one of the internals gurus
can confirm or not. This was actually something that was very beneficial
when I was developing an app using POE that forked off processes to run
concurrently. It meant we didn't have to reload some fairly heavy
modules (POE, Log4perl, Mail::Box, etc.) which made the forking fast.
This is a good reason why you shouldn't shell out to another Perl
interpreter specifically, which is why the system was reengineered. It
was reengineered from a set of 6 independent script calls which each had
to load modules independently each time, to a single Perl head that
forked each of the 6 steps, meaning the modules were loaded once when
the daemon was run, saving a ton of loading time over the life of the
process.
But the overhead for a forked/shelled process is either a lot or a
*really* lot depending on how it functions and how optimized the
underlying OS is for forking processes.
http://danconia.org
|
|
|
|
|