RE: host id
I whole heartedly agree! top post rules! Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams Ryan Frantz [EMAIL PROTECTED] med-llc.com To Wiggins d'Anconia 06/09/2005 04:13 [EMAIL PROTECTED], PM[EMAIL PROTECTED] cc [EMAIL PROTECTED], 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:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 4:02 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; 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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
[EMAIL PROTECTED] [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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? I'll take that one on the chin. ;) 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. 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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. 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 :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
[EMAIL PROTECTED] wrote: Ryan Frantz wrote: Spot the flaw. Please get Outlook-QuoteFix. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
[EMAIL PROTECTED] rum-health.org To 06/10/2005 10:55 beginners@perl.org AM cc Subject RE: host id 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. 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
On Fri, 10 Jun 2005 [EMAIL PROTECTED] 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
Sorry for the inline answer and my bad english. [EMAIL PROTECTED] 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 [EMAIL PROTECTED] med-llc.com To Wiggins d'Anconia 06/09/2005 04:13 [EMAIL PROTECTED], PM[EMAIL PROTECTED] cc [EMAIL PROTECTED], 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:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 4:02 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; 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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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? 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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response very useful citation... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] 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 -- To unsubscribe, e-mail
Top Posting (was RE: host id)
VERY fascinating discussions about the pros and cons of top-posting SNIPPED While I'm sure the arguments for and against the top-posting practices of Internet email lists are wonderful, perhaps we can change the subject of these emails. I keep hoping someone will tell me more about the OP's hostname questions and instead I read these (again, fascinating) arguments instead. --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Top Posting (was RE: host id)
Larsen, Errin M HMMA/IT wrote: VERY fascinating discussions about the pros and cons of top-posting SNIPPED While I'm sure the arguments for and against the top-posting practices of Internet email lists are wonderful, perhaps we can change the subject of these emails. I keep hoping someone will tell me more about the OP's hostname questions and instead I read these (again, fascinating) arguments instead. --Errin Good call. I installed Outlook-Quotefix. Seems to work well, though installing it is a violation of my organization's software policy. It should be noted that Outlooks preferences have to be set back to the default for it to work right. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
On 6/10/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I whole heartedly agree! top post rules! Apparently, so does Lotus Notes. My deepest sympathies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
yeah thanks... company email system... Ar... notes is evil. for that fact IBM is evil! Dave Gray [EMAIL PROTECTED] omTo beginners@perl.org 06/10/2005 02:31 cc PM Subject Re: host id Please respond to Dave Gray [EMAIL PROTECTED] om On 6/10/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I whole heartedly agree! top post rules! Apparently, so does Lotus Notes. My deepest sympathies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
On 6/9/05, Wiggins d'Anconia [EMAIL PROTECTED] 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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
Dave Gray wrote: On 6/9/05, Wiggins d'Anconia [EMAIL PROTECTED] 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. 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
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:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 4:02 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; 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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: host id
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. 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. 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', Matter of preference really. I like using regex. -Original Message- From: Bret Goodfellow [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: host id
[EMAIL PROTECTED] 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. 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 sysadmins 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,