RE: Chomping in wrong place...
This worked. I forgot about chomping that. Thanks. -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 1:09 PM To: Wert, Nathaniel J Cc: [EMAIL PROTECTED] Subject: Re: Chomping in wrong place... On Aug 14, Wert, Nathaniel J said: >> open INPUT, $file or die "\n\nCan't open file $INPUT: $!\n"; That should be $file in your error message. >> while () { >> $node = $_; Why don't you chomp $node here? It will have a newline at the end. while (my $node = ) { chomp $node; system "script1 -r $db -7 $node -v 9"; } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Chomping in wrong place...
> Here is the basis of the script: > > #!/usr/bin/perl -w > > my $file; > my $db; > my $node; > > print "Prompt user for file name"; > chomp($file = ); > > print "Prompt user for database"; > chomp($db = ); > > open INPUT, $file or die "\n\nCan't open file $INPUT: $!\n"; > > while () { > $node = $_; > system("script1 -r $db -7 $node -v 9"); > } > > close(INPUT); > -- > > The problem with the script is that the command "script1 -r -7 > -v 9" gets executed as "cript -r -7 " and then the next command is > the rest of the previous command "-v 9" and then it continues to cycle. I have > found the removing the second chomp produces the command "script1 -r ", > but it does not complete the rest of the command. What I really need to know if why > is a chomp on a variable effecting its processing in a completely different area of > the code and how do I fix it? > > Thanks ahead of time to anyone that contributes to my dilemma.
malloc equivalent.
Just would like to know if there is a malloc equivalent. Thanks. --- Nathaniel J. Wert Computer Associates Quality Assurance Engineer, Development tel: +1 513 229 2300 [EMAIL PROTECTED]
File::Find::find problem.
> Script purpose: > I am trying to search an extremely large mounted dir on NT and find the location of >any file or dir that starts with a certain string that is given on command line. > > Problem: > File::Find::find({wanted => \&wanted}, 'e:\\'); > There is something about this line that is just not working. I can enter a specific >directory, such as 'e:\\foobar' and get the results that I desire. However if I >leave it as it is in the script, the file does not display. I also get an opendir() >error entering a certain dir that does not allow the script to complete. > > Questions: > 1) Why will the script work if the next level dir is specified, but will not work >off the root of the mounted dir? > 2) If I specify no_chdir, will the find still search the entire dir tree or just the >next dir level? > > Thanks to all that help. > > FILE1: > > #! C:\Perl\bin\perl.exe -w > eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}' > if 0; #$running_under_some_shell > > use strict; > use File::Find (); > #open(OUT,">> output.txt") || die "can't open output.txt: $!"; > > # Set the variable $File::Find::dont_use_nlink if you're using AFS, > # since AFS cheats. > > # for the convenience of &wanted calls, including -eval statements: > use vars qw/*name *dir *prune/; > *name = *File::Find::name; > *dir= *File::Find::dir; > *prune = *File::Find::prune; > > # Traverse desired filesystems > File::Find::find({wanted => \&wanted}, 'e:\\'); > > #close(OUT); > print "\nfinished\n"; > exit; > > sub wanted { > print "*"; > /^$ARGV[0].*\z/s && > print("$name\n"); > } > > EOF > > > > Thanks. >
system() output question.
I would like to be able to take the output of system(some cmd) and send it to a filehandle. How is this possilbe? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32::Console.
Looking for the same thing. -Original Message- From: Ryan Guy [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 13, 2001 3:25 PM To: '[EMAIL PROTECTED]' Subject: Win32::Console. If anyone knows where I can find some half way decent examples and explanations I would be thrilled thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
win32 peekinput
Is there some trick to this? use Win32::Console; $con = Win32::Console->new(STD_INPUT_HANDLE); @event = $con->PeekInput(); $tmp = chr($event[5]); print "\n The character typed was: $tmp \n"; If I use Input() instead of PeekInput() it works fine and the docs say that it is suposed to work the same as input, but does not remove input from the keyboard buffer. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: win32 console input problem
Thank you. This worked. I was incorrectly figuring the breakdown of the array. Next question, isn't peekinput supposed to work the same way. The program runs without any error, but the array is not populated with peekinput. Thanks again. -Original Message- From: Herb Hall [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 12, 2001 3:02 PM To: [EMAIL PROTECTED] Subject: Re: win32 console input problem Try this: use Win32::Console; $con = Win32::Console->new(STD_INPUT_HANDLE); @event = $con->Input(); print "$event[0] - event type: 1 for keyboard\n"; print "$event[1] - key down: TRUE if the key is being pressed, FALSE if the key is being released\n"; print "$event[2] - repeat count: the number of times the key is being held down\n"; print "$event[3] - virtual keycode: the virtual key code of the key\n"; print "$event[4] - virtual scancode: the virtual scan code of the key\n"; print "$event[5] - char: the ASCII code of the character (if the key is a character key, 0 otherwise)\n"; print "$event[6] - control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)\n"; You want $event[5]. Herb Hall - Original Message - From: "Nathaniel Wert" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 12, 2001 12:11 PM Subject: win32 console input problem > Here's the code: > > use Win32::Console; > $con = Win32::Console->new(STD_INPUT_HANDLE); > @event = $con->Input(); > $tmp = $event[6]; > print "\n The character typed was: $tmp \n"; > > For some reason $event[6] is always returning the > ascii value of the space character no matter what I > type. I am not really sure why. > > Thank ahead of time for the help. > > __ > Do You Yahoo!? > Check out Yahoo! Shopping and Yahoo! Auctions for all of > your unique holiday gifts! Buy at http://shopping.yahoo.com > or bid at http://auctions.yahoo.com > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: gethostbyname and getnetbyname
I just realized I was not chomping . Thanks. -Original Message- From: Wert, Nathaniel Sent: Friday, November 02, 2001 5:19 PM To: 'Maxim Berlin' Cc: '[EMAIL PROTECTED]' Subject: RE: gethostbyname and getnetbyname Maybe it comes in the statement before that: $nodename = ; $iaddr = gethostbyname($nodename); ($a,$b,$c,$d) = unpack('C4',$iaddr); $ipaddress = "$a.$b.$c.$d"; print $ipaddress; I have debugged this numerous times and I can't seem to understand why gethostbyname does not return anything. I have tried with both the hostname and the hostname.foo.com notation and it does not work. It does work when I replace $nodename with 'node.foo.com' but I can't get the imputed variable to work? Thanks, Nate. -Original Message- From: Maxim Berlin [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 4:54 PM To: [EMAIL PROTECTED] Subject: Re: gethostbyname and getnetbyname Hello Nathaniel, Friday, November 02, 2001, Wert, Nathaniel <[EMAIL PROTECTED]> wrote: WN> 1) I can get gethostbyname to work in this format: WN> gethostbyname('node.foo.com'). I need it to work in the following WN> format: gethostbyname($nodename). Is this not set up for that? $nodename='node.foo.com'; $ent=gethostbyname($nodename); where is your problem? example: use Socket; use Net::hostent; $h = gethostbyname("www.perl.com"); print "name:", $h->name," address:",inet_ntoa($h->addr),"\n", Best wishes, Maximmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: gethostbyname and getnetbyname
Maybe it comes in the statement before that: $nodename = ; $iaddr = gethostbyname($nodename); ($a,$b,$c,$d) = unpack('C4',$iaddr); $ipaddress = "$a.$b.$c.$d"; print $ipaddress; I have debugged this numerous times and I can't seem to understand why gethostbyname does not return anything. I have tried with both the hostname and the hostname.foo.com notation and it does not work. It does work when I replace $nodename with 'node.foo.com' but I can't get the imputed variable to work? Thanks, Nate. -Original Message- From: Maxim Berlin [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 4:54 PM To: [EMAIL PROTECTED] Subject: Re: gethostbyname and getnetbyname Hello Nathaniel, Friday, November 02, 2001, Wert, Nathaniel <[EMAIL PROTECTED]> wrote: WN> 1) I can get gethostbyname to work in this format: WN> gethostbyname('node.foo.com'). I need it to work in the following WN> format: gethostbyname($nodename). Is this not set up for that? $nodename='node.foo.com'; $ent=gethostbyname($nodename); where is your problem? example: use Socket; use Net::hostent; $h = gethostbyname("www.perl.com"); print "name:", $h->name," address:",inet_ntoa($h->addr),"\n", Best wishes, Maximmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
gethostbyname and getnetbyname
Thank you for the help earlier, but I am still having a problem. 1) I can get gethostbyname to work in this format: gethostbyname('node.foo.com'). I need it to work in the following format: gethostbyname($nodename). Is this not set up for that? 2) I tried to alternatively use getnetbyname, but I don't think that it is loaded into the standard distrabution. I bet it has something to do with the fact that I am trying to do this with Active Perl on NT. Thank for the help ahead of time. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Parsing syscall input.
I am trying to make a feable attempt at parsing a nslookup call. All I actually want is the IP address. So I figured I would do the following: $ticker = 0; foreach $_ (`nslookup $nodename`) { $_ = $out[$ticker]; $ticker++; } print $out[0]; I am getting a uninitalized error for $out[0]. Three questions: 1) What am I doing wrong with this? I am not sure why this is not working. 2) I orginally thought that $_ was a array value and I could just do a "$_ = @foo". I have found that I am mistaken. Is there any way to get the output into an array from by line of input? 3) General suggestions on an easier way to do this. Is there an actual function that will do an nslookup or get the ip address of a nodename? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]