Premature end of script headers
Hello, I created my first Perl script from book and internet sources. I tried it out at home and it worked fine. I then uploaded it to work's Apache server, changed the permissions, and put it in the cgi-bin folder. Now I get a Premature end of script headers message. Can anyone tell me more about this error message and reasons for it appearing. Thanks Kim
RE: Premature end of script headers
Kim, If you're trying to get the results to print in a browswer, you have to send the content type to the browser in the headers. Did you do either of these things prior to whatever routine prints your results? use CGI; $query = new CGI; print $query-header; or print Content-type: text/html\n\n; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Premature end of script headers
--- Kim Forbes [EMAIL PROTECTED] wrote: Hello, I created my first Perl script from book and internet sources. I tried it out at home and it worked fine. I then uploaded it to work's Apache server, changed the permissions, and put it in the cgi-bin folder. Now I get a Premature end of script headers message. Can anyone tell me more about this error message and reasons for it appearing. Hi Kim, Could you please show us the code? Also, when you say you tried it out at home, did you run it from a command line or did you run it through a Web server. Each can behave significantly different from the other one. Cheers, Ovid = Ovid on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Premature end of script headers
Sure, Here is the code. When I tried it out at home, I uploaded it to Tripod (The free web-creation site.) I must add that I tested everything, but the mail portion of the program (Tripod requires a special Tripod Mail module that I felt was too much work for what I was trying to do. I may be wrong!) #!/usr/bin/perl-w print Content-type:text/html\n\n; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(//, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg; $FORM{$name} = $value; } # where is the mail program? $mailprog = 'usr/lib/sendmail'; # this opens an output stream and pipes it directly to the # sendmail program. If sendmail can't be found, abort nicely # by calling the dienice subroutine (see below) open (MAIL, |$mailprog -t) or dienice(Can't access $mailprog!\n); # here we're printing out the header info for the mail # message. You must specify who it's to, or it won't be # delivered: print MAIL To: $FORM {'emailrec'}($FORM{'name'});\n; # Reply-to can be set to the email address of the sender, # assuming you have actually defined a field in your form # called 'email'. print MAIL Reply-to: $FORM{'email'} ($FORM{'name'})\n; # print out a subject line so you know it's from your form cgi. # The two \n\n's end the header section of the message. # anything you print after this point will be part of the # body of the mail. print MAIL Subject: Form Data\n\n; # here you're just printing out all the variables and values, # just like before in the previous script, only the output # is to the mail message rather than the followup HTML page. foreach $key (keys(%FORM)) { print MAIL $key = $FORM{$key}\n; } # when you finish writing to the mail message, be sure to # close the input stream so it actually gets mailed. close(MAIL); # now print something to the HTML page, usually thanking # the person for filling out the form, and giving them a # link back to your homepage print EndHTML; HTMLHEADTITLEYour data has been submitted/TITLE/HEADBODY H2Thank You/H2 Thank you for submitting this form. Your form has been delivered to EndHTML print $FORM{'email'} ($FORM{'name'})\n; print H3You have submitted this information/H3 \n; foreach $key (keys(%FORM)) { print $key = $FORM{$key}br; } print /body/html; exit(0); # The dienice subroutine, for handling errors. sub dienice { my($errmsg) = @_; print h2Error/h2\n; print $errmsgp\n; print /body/html\n; exit (0); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Premature end of script headers
Scott, Thanks for the reply, but I did have the print Content-type: text/html/n/n line in my code. Thanks again Kim - Original Message - From: Scot Robnett [EMAIL PROTECTED] To: Kim Forbes [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:50 AM Subject: RE: Premature end of script headers Kim, If you're trying to get the results to print in a browswer, you have to send the content type to the browser in the headers. Did you do either of these things prior to whatever routine prints your results? use CGI; $query = new CGI; print $query-header; or print Content-type: text/html\n\n; - Scot Robnett inSite Internet Solutions [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: Premature end of script headers
Kim, It appears to be the header issue I mentioned before. Before print EndHTML; You should print the text/html header. print Content-type: text/html\n\n; print EndHTML; or use CGI; $q = new CGI; print $q-header; print EndHTML; # etc. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Premature end of script headers
Yes, but it's not correct, there's your premature end of script header right there. You have: print Content-type:text/html\n\n; It should be: print Content-type: text/html\n\n; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Premature end of script headers
Hi Kim, I hope you don't take any of this personally. It's certainly not meant that way. --- Kim Forbes [EMAIL PROTECTED] wrote: #!/usr/bin/perl-w There should be a space after the -w. print Content-type:text/html\n\n; There should be a space after the colon. This is one of the reasons why CGI.pm is preferable: use CGI qw(:standard); print header; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(//, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg; $FORM{$name} = $value; } Numerous bugs here. Rather than go through all of them, I'll just post a link to my course where I detail them: http://users.easystreet.com/ovid/cgi_course/lesson_two/lesson_two.html # where is the mail program? $mailprog = 'usr/lib/sendmail'; Without the leading slash, isn't this going to be relative to the current working directory? I'd also recommend that you use strict. Here are a couple of useful links: http://www.perlmonks.org/index.pl?node_id=87628 http://www.perlmonks.org/index.pl?node_id=108286 Cheers, Ovid = Ovid on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Premature end of script headers
Greetings; That will not cause the problem using Apache and IE 6.0 It might in other combinations, but generally spaces are not significant if other punctuation is doing the job. Check the error logs for file not found which is generally a permissions problem. Also, for a valid path-to-perl in the first line. It may be different on your host than it is on your home computer. Good Luck! Dennis On Mon, 24 Mar 2003, Scot Robnett wrote: Yes, but it's not correct, there's your premature end of script header right there. You have: print Content-type:text/html\n\n; It should be: print Content-type: text/html\n\n; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PHP and Oracle
This isn't really a good place for this questions Stephen as it really has nothing to do with Perl. I suggest you try a dedicated PHP list, or stick with the AIX one that you also posted to. Regards, Daniel Hopkirk http://hawkesbay.pm.org ICQ#:39905948 - Original Message - From: Stephen Spalding [EMAIL PROTECTED] To: AIXmailingList [EMAIL PROTECTED]; CGI [EMAIL PROTECTED] Sent: Tuesday, March 25, 2003 6:38 AM Subject: PHP and Oracle Anyone have experience installing PHP4 on AIX for use with Oracle? I've just recently received a request to put it on an AIX 4.3.3 server, and I'm thinking about going to the Linux toolbox page to download a smit installable version of PHP. However, I'm concerned about if it will be able to connect to Oracle right out of the box. Anyone have any suggestions? Thanks! -Stephen Spalding __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.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]
Re: Using Print -strange behavior
Hello Ovid This is the code that I am trying to run #!/usr/bin/perl my $a=Hello World; print $a; Thanks, JL Ovid [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Jose Luis Martinez [EMAIL PROTECTED] wrote: Hello All I installed Linux 8.0(kernel 2.4.18-14) and Perl V5.8.0 and when I try to run a Perl program with the line print Hello World it does not work, just perl executed it without an error. I checked it the script using perl -c script_name and it return OK Hello Jose, While that sounds simple enough to be error free, if you could show us the code, it would be helpful to at least rule out obvious problems. Cheers, Ovid = Ovid on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Print -strange behavior
Jose Luis Martinez wrote at Sun, 23 Mar 2003 15:04:42 -0800: This is the code that I am trying to run #!/usr/bin/perl my $a=Hello World; print $a; Runs fine for me, allthough I wouldn't use $a as a variable. (It's already a global variable used e.g. in sortings, see perldoc perlvar for details) Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1) Automated FTP 2) txt to html 3) pstools vs WMI
Pradeep Goel wrote at Mon, 24 Mar 2003 11:24:15 +0530: Hi All ,pls answer if u know anything out of 3 different questions. If you have 3 different questions, ask in 3 different articles, not in one ! 1) Can somebody give some pointers where to look for or any particularly good one ( free ofcourse) automated ftp tool which can be used for transfering a txt/doc file from my win XP system to a unix server ?. And your Perl question is ? (This is a Perl newsgroup). If you want to transfer _one_ txt/doc file just use the ftp tool of WinXP from the command line. 2) Also if somebody what I can do to make a page html instead of txt or doc - keeping up the format ( need not be exact format but it should not just be a messed up one). when i rename from .doc to .html or use copy command ( i.e. on windows machine) the format goes off completely - what left is contiguous words that's all ?. And your Perl question is ? (This is a Perl newsgroup). Use any of the many -to-html converters. 3) last question could there be any problem ( like ease of modification or flexibility related) if i am using pstools to get remote information from win systems instead of WMI scripts. The scripts thus reduced to a total of hardly 4-5 lines instead of longer 2-3 page scripts in WMI. Is there any adv of using WMI in place of pstools ?. And your Perl question is ? (This is a Perl newsgroup). Sorry, I don't know what WMI is and I touched something like pstools only in LaTeX up till now. Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1) Automated FTP 2) txt to html 3) pstools vs WMI
- Original Message - From: Janek Schleicher [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, March 24, 2003 2:57 PM Subject: Re: 1) Automated FTP 2) txt to html 3) pstools vs WMI Pradeep Goel wrote at Mon, 24 Mar 2003 11:24:15 +0530: Hi All ,pls answer if u know anything out of 3 different questions. If you have 3 different questions, ask in 3 different articles, not in one ! Clarify your logic behind that . As far as mine is concerned it would have been diffiuclt for me to write 9 mails ( if I am writing to 3 groups) also wasted the reader's time for reading 3 mails rather then 1 ( I have already mentioned question topics in subject line itself ) . 1) Can somebody give some pointers where to look for or any particularly good one ( free ofcourse) automated ftp tool which can be used for transfering a txt/doc file from my win XP system to a unix server ?. And your Perl question is ? (This is a Perl newsgroup). If you would have been knowing anything of WMI ( in perl ) probably you wouldn't have asked this useless questions at least in response to my 3rd question which is entirely a perl question only none else ( then u wouldn't have copied this question anywhere else too ) . Half a knowledge is dangerous thing . If you want to transfer _one_ txt/doc file just use the ftp tool of WinXP from the command line. read carefully I have asked for automated ftp not just ftp - my subject line mentions it very well . even then thanks for trial . 2) Also if somebody what I can do to make a page html instead of txt or doc - keeping up the format ( need not be exact format but it should not just be a messed up one). when i rename from .doc to .html or use copy command ( i.e. on windows machine) the format goes off completely - what left is contiguous words that's all ?. And your Perl question is ? (This is a Perl newsgroup). It is my perl program only which is generating this doc/txt file which I need to convert to html then ftpied to unix server . I all of perl programmers work in either windows or unix here does have such similar interaction not that they only only work within limits of perl ( else you wouldn't have been knowing about these html converters - do you expect me to search for txt to html mail list then subscribe to that list then post this question) Use any of the many -to-html converters. thanks . 3) last question could there be any problem ( like ease of modification or flexibility related) if i am using pstools to get remote information from win systems instead of WMI scripts. The scripts thus reduced to a total of hardly 4-5 lines instead of longer 2-3 page scripts in WMI. Is there any adv of using WMI in place of pstools ?. And your Perl question is ? (This is a Perl newsgroup). go read perl module Win32::OLE - thus how to use WMI in perl also learn how to use pstools in perl - those who uses them in perl - they knows this is only a perl question . Sorry, I don't know what WMI is and I touched something like pstools only in LaTeX up till now. Sorry but help was much lesser then the time you wasted of mine to respond to your unnecessary queries . If you want to help somebody - help else just delete the mail no body forces you to read it . - pradeep Cheerio, Janek -- 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: 1) Automated FTP 2) txt to html 3) pstools vs WMI
Pradeep Goel wrote: Hi All ,pls answer if u know anything out of 3 different questions. Hello Pradeep. Welcome to perl.beginners. A lot of us here know a lot about Perl, and between us we can help you with almost any Perl problem that a Perl beginner might come across. 1) Can somebody give some pointers where to look for or any particularly good one ( free of course ) automated ftp tool which can be used for transfering a txt/doc file from my win XP system to a unix server ?. In Perl you would want to use Net::FTP, or take a look at LWP, which will let you handle several common Internet protocols. But I know of no ready-written Perl application ( free, of course ) that will do the job. One approach might be the Perl 'system' function, which will allow you to write something like system 'ftp' but that requires that all of the necessary information can be included in the command line. You might check the XP help files to see if this is possible. A full solution would need to send commands to the ftp utility and receive results back from it. This would need the IPC::Open2 module, which is essentially an enhancement of standard pipe operation that allows bidirectional communication. If you add a layer on top of this which reads and writes STDIN and STDOUT, then you could pass commands from the keyboard to the utility and display the corresponding output, just as if you were controlling it directly. 2) Also if somebody what I can do to make a page html instead of txt or doc - keeping up the format ( need not be exact format but it should not just be a messed up one). when i rename from .doc to .html or use copy command ( i.e. on windows machine) the format goes off completely - what left is contiguous words that's all ?. It sounds here as if you want to convert a MS Word file to HTML? Your idea of renaming files is a good one, but even this can get a little complicated at times, with file protection and ownership to take account of, as well as unprintable characters embedded in filenames. Perl could help you here. It has a function 'rename' which will change the name of a file for you. The syntax is rename OLDNAME,NEWNAME but beware, as if you already have a file called NEWNAME, it will be overwritten. You could check out the help files on your copy of Word, but I'm afraid that, to my knowledge, there are no Perl modules which will parse a Windows Help file. You may however be interested in the Pod2WinHlp module, which will translate Perl's 'Plain Old Documentation' to a Windows Help. Should you need to write your own Perl translation module then we will help you all we can. 3) last question could there be any problem ( like ease of modification or flexibility related ) if i am using pstools to get remote information from win systems instead of WMI scripts. The scripts thus reduced to a total of hardly 4-5 lines instead of longer 2-3 page scripts in WMI. Is there any adv of using WMI in place of pstools ?. There's the rub, you see: there could be any number of problems I'm afraid. It really depends on what information you're getting, the method you have used to connect to the remote system, any security systems that protect the remote data, and how you want to process the information once it is retrieved. No interface exists to my knowledge which provides a straightforward Perl interface to either Windows Management Instrumentation or pstools, but it can certainly help with the processing of the data once it has arrived. Being a 'Practical Extraction and Reporting Language' it is ideally suited to this sort of application, and I would direct you to the 'perlform' part of the documentation, which will help you neatly arrange reports on the accumulated data. If you have access to the administrator of the remote system, I also suggest that you evangelise the Perl approach. If you can get someone else to format the data as you would wish before you even retrieve it, then it can only be an advantage to you. Once your remote partner has seen the possibilities that Perl offers I'm sure he would be only too willing to cooperate. Please come back to us if you have any further questions about the Perl approach to problem solving. We will be only too willing to assist. Rob:- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Database access CGI
I wrote a small program accessing a Mysql database. All works fine when I run it from shell, but when I try to use it as CGI using apache 2.0 I'm having this kind of trouble: when he access to the database, looks like he append to the user name the domain...so if all works properly from shell with the user 'ADMIN' the access is denied to the user '[EMAIL PROTECTED]' that the CGI is trying to use to connect to the DB. what can I do? Frank __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database access CGI
Francesco Del Vecchio [EMAIL PROTECTED] wrote: I wrote a small program accessing a Mysql database. All works fine when I run it from shell, but when I try to use it as CGI using apache 2.0 I'm having this kind of trouble: when he access to the database, looks like he append to the user name the domain...so if all works properly from shell with the user 'ADMIN' the access is denied to the user '[EMAIL PROTECTED]' that the CGI is trying to use to connect to the DB. Hi Frank. It looks like your script may be using the username intended for access to the the host, not the one used to access the database. The string '[EMAIL PROTECTED]' is a host name with a username included, and can be used in a URL: http://[EMAIL PROTECTED]/cgi-bin/script.pl so I wonder if somehow you're using the string in the wrong context. Are you fetching the username from the evironment variables provided by Apache? We can only speculate as to what your problem may be until we know a little more about your script. Can you post an extract of what you think is the relevant area? Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Printing epoch time
how can I print the today date (DD MM YY HH MM SS) in epoch format? Frank __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database access CGI
--- Rob Dixon [EMAIL PROTECTED] wrote: Hi Frank. We can only speculate as to what your problem may be until we know a little more about your script. Can you post an extract of what you think is the relevant area? Cheers, Rob Hi Rob...here you have the code: === my $dbconnection='DBI:mysql:ROI';#The connection string to the db my $dbuser='kiwadmin'; #The user of the DB my $dbpwd='kiwadmin';#The db pwd my $dbh=DBI-connect($dbconnection,$dbuser,$dbpwd) or die cannot connect to the DB; Now..in the Apache log I can read this: DBI-connect(ROI) failed: Access denied for user: '[EMAIL PROTECTED]' === How can I avoid the Webserver add domain to the user? tnx Frank __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1) Automated FTP 2) txt to html 3) pstools vs WMI
Hi Rob Thanks a lot . You the remote partner seems to be the two extremes . A really impressive mail with lot of positive attitude . Can you tell something more about LWP use for my solution i.e. how to transer a doc/html file automatically on daily basis from my windows machine to a unix machine . Rob I am easliy able to make the page as html that is not the issue - probably i need some html converter to keep up the formatting else I don't think even perl's rename command could be helpfull in keeping up the formatting . I couldn't very well understand the answer to 3rd one . Do you mean that WMI pstools both r not perlish way ? ( not clear ) . I think WMI should be a pure perlish way ( we naturally need to use files supplied with OS WMI is also the one) . There I still many parts of your mail which I am going through like Net::FTP also to check out an automated ftp ,will ask you or list with next set of problems :)) . Thanks Regards Pradeep Rob Dixon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Pradeep Goel wrote: Hi All ,pls answer if u know anything out of 3 different questions. Hello Pradeep. Welcome to perl.beginners. A lot of us here know a lot about Perl, and between us we can help you with almost any Perl problem that a Perl beginner might come across. 1) Can somebody give some pointers where to look for or any particularly good one ( free of course ) automated ftp tool which can be used for transfering a txt/doc file from my win XP system to a unix server ?. In Perl you would want to use Net::FTP, or take a look at LWP, which will let you handle several common Internet protocols. But I know of no ready-written Perl application ( free, of course ) that will do the job. One approach might be the Perl 'system' function, which will allow you to write something like system 'ftp' but that requires that all of the necessary information can be included in the command line. You might check the XP help files to see if this is possible. A full solution would need to send commands to the ftp utility and receive results back from it. This would need the IPC::Open2 module, which is essentially an enhancement of standard pipe operation that allows bidirectional communication. If you add a layer on top of this which reads and writes STDIN and STDOUT, then you could pass commands from the keyboard to the utility and display the corresponding output, just as if you were controlling it directly. 2) Also if somebody what I can do to make a page html instead of txt or doc - keeping up the format ( need not be exact format but it should not just be a messed up one). when i rename from .doc to .html or use copy command ( i.e. on windows machine) the format goes off completely - what left is contiguous words that's all ?. It sounds here as if you want to convert a MS Word file to HTML? Your idea of renaming files is a good one, but even this can get a little complicated at times, with file protection and ownership to take account of, as well as unprintable characters embedded in filenames. Perl could help you here. It has a function 'rename' which will change the name of a file for you. The syntax is rename OLDNAME,NEWNAME but beware, as if you already have a file called NEWNAME, it will be overwritten. You could check out the help files on your copy of Word, but I'm afraid that, to my knowledge, there are no Perl modules which will parse a Windows Help file. You may however be interested in the Pod2WinHlp module, which will translate Perl's 'Plain Old Documentation' to a Windows Help. Should you need to write your own Perl translation module then we will help you all we can. 3) last question could there be any problem ( like ease of modification or flexibility related ) if i am using pstools to get remote information from win systems instead of WMI scripts. The scripts thus reduced to a total of hardly 4-5 lines instead of longer 2-3 page scripts in WMI. Is there any adv of using WMI in place of pstools ?. There's the rub, you see: there could be any number of problems I'm afraid. It really depends on what information you're getting, the method you have used to connect to the remote system, any security systems that protect the remote data, and how you want to process the information once it is retrieved. No interface exists to my knowledge which provides a straightforward Perl interface to either Windows Management Instrumentation or pstools, but it can certainly help with the processing of the data once it has arrived. Being a 'Practical Extraction and Reporting Language' it is ideally suited to this sort of application, and I would direct you to the 'perlform' part of the documentation, which will help you neatly arrange reports on the accumulated data. If you have access to the administrator of the remote system, I also suggest that you evangelise the Perl
Re: Printing epoch time
Francesco Del Vecchio wrote: how can I print the today date (DD MM YY HH MM SS) in epoch format? Frank perldoc -f time localtime gmtime perldoc Time::Local (-- I think this is what you're after. if not, please clarify for us) POSIX (and search for the strftime function) There's also Time::HiRes if you're interested in that sort of thing. That should be enough info for you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
rename in windows doesn't work
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi everyone, I am having some problems with a script. Currently the script reads: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; @filenames = readdir (DIR) or die Can't Hold Filenames \n; foreach $name (@filenames) {if ($name eq blah.dat) {rename ($name, blah.old) or die sorry couldnt complete task cause $! } }; C:\scriptzperl -w open4.pl sorry couldnt complete task cause No such file or directory at open4.pl line 7. Yet when I run this code: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; @filenames = readdir (DIR) or die Can't Hold Filenames \n; foreach $name (@filenames) { print $name \n; } I get: C:\scriptzperl -w open3.pl . .. blah.dat FAD3.TXT osctalk.log sec_scan.html Can anyone explain to me what I am doing wrong? Thx again, leon -BEGIN PGP SIGNATURE- Version: PGP 8.0 iQA/AwUBPn8PEEk2S2y0JhBMEQLtEACgvdYDCL97knE1QN7YQ1F1AM+FOhQAoN3E N9WqX0J+zsHuuOPBcG1RNM6Z =FV57 -END PGP SIGNATURE- INDEPENDENCE COMMUNITY BANK CONFIDENTIALITY NOTICE: This message (and any attachment) is confidential and intended for the sole use of the individual or entity to which it is addressed. If you are not the intended recipient, you must not review, retransmit, convert to hard-copy, copy, use or disseminate this email or any of its attachments. If you received this email in error, please notify the sender immediately and delete it. This notice is automatically appended to all Internet email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename in windows doesn't work
On Mon, 24 Mar 2003, Rosenstein, Leon wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi everyone, I am having some problems with a script. Currently the script reads: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; @filenames = readdir (DIR) or die Can't Hold Filenames \n; foreach $name (@filenames) {if ($name eq blah.dat) {rename ($name, blah.old) or die sorry couldnt complete task cause $! } }; readdir returns only the filename, it does not prefix the directory name before it. You will have to do this rename (c:/temp/$name, c:/temp/blah.old); But why loop through readdir when you can just do this # if the file exists rename it if (-e c:/temp/blah.dat) { rename (...); } perldoc -f -x # you can choose the appropriate file test for your program C:\scriptzperl -w open4.pl sorry couldnt complete task cause No such file or directory at open4.pl line 7. Yet when I run this code: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; @filenames = readdir (DIR) or die Can't Hold Filenames \n; foreach $name (@filenames) { print $name \n; } I get: C:\scriptzperl -w open3.pl . .. blah.dat FAD3.TXT osctalk.log sec_scan.html Can anyone explain to me what I am doing wrong? Thx again, leon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename in windows doesn't work
Hi Leon Leon Rosenstein [EMAIL PROTECTED] wrote: I am having some problems with a script. Currently the script reads: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; Don't put \n on the end of a die string, otherwise the Perl interpreter won't tell you the line number of the failure. @filenames = readdir (DIR) or die Can't Hold Filenames \n; @filenames now contains a list of the file names only ( without a path ). foreach $name (@filenames) {if ($name eq blah.dat) {rename ($name, blah.old) or die sorry couldnt complete task cause $! } }; This will try to rename .\blah.dat C:\scriptzperl -w open4.pl sorry couldnt complete task cause No such file or directory at open4.pl line 7. Please try to indicate which is the line in question in your script. In this case it's obvious because of the die string, but the script you have shown us only has four lines! Can anyone explain to me what I am doing wrong? You are unlikely to have C:\temp as your current directory, so you will need to either prefix the name of the file with its path, or do chdir 'C:\temp' before running the rename. This should do the trick: my $dir = 'C:\temp'; opendir DIR, $dir or die $!; while ($name = readdir DIR) { next unless $name eq blah.dat; $name = join '\\', $dir, $name; rename $name, blah.old or die $!; } closedir DIR; HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: networking with perl
Hi Dan, Hii, please post to the list so everyone can learn and help. I have a little more problem in running system command from cgi file. Even I wrote a perl file so that I can run the system command from the perl file. But the perl file is also not executing the system command. I could run the short commands from the cgi file. I am sending the scripte for your kind considerations, Looking forward for your reply. With regards, Soumyadeep I am sending the request from the perl file I think I see the path you're trying to take. What is the problem you're having? I can read that the perl script is not executing the system command but Which system call? What is ihappening that makes you think it's not executing? Any errors in any logs? Which of the 3 scripts below is it happening in? Etc. etc.. send.pl-- #!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use LWP; my $ua = new LWP::UserAgent; my $req = new HTTP::Request POST = 'http://localhost/cgi- bin/bic_genscan/file3.cgi'; $req-content_type('application/x-www-form-urlencoded'); $req-content('st=atgtcgatcagctacgatc'); my $res = $ua-request($req); if($res-is_success){ print $res-content; }else{ print Error: .$res-status_line.\n; } exit; Receiving the request by cgi file file3.cgi--- #!/usr/bin/perl -w use CGI; print Content-type:text/plain\n\n; $query = new CGI; print blast\n; $str = $query-param('st'); print here the string is : $str\n; system(./perl1.pl); --- And processing the request by another perl file perl1.pl- #!/usr/bin/perl $str = shift; How come you never use this variable? print received the sequence\n; system(/home/soumya/Application/BLAST/blastall -p blastn -d /home/soumya/Application/BLAST/data/ecoli.nt -i /var/www/cgi-bin/bic_genscan/testseq); print done...\n; __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: networking with perl
Hi Dan, Howdy, post to the list so we can all share :) I wrote a simple script that is sending a request to localhost and receiving the response with LWP. I wrote yesterday it was running fine on yesterday, but as I am trying to run today it is ending up with the error 403 Forbidden . I am sending the script along with this mail bellow. I've checked the file permission of file3.cgi and put it to -rwxrwxrwx. Make it 755 instead. Also the 403 could mean that you need to Log in withusername and password. What happens when you open the Url in question in a browser? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Searching for the right regular expressions
Dear Perl experts, I'm trying to find the right regular expressions to do some simple (?) string processing. Can anyone tell me how to do these? 1. Given a string consisting of substrings delimited by colons, such as :B520:L201:M:M260:8:G607:, how can I a. remove the single-character and all-numeric substrings (M and 8 in this example), leaving the rest alone? b. remove all but the single-character and all-numeric substrings and leave the rest alone? c. remove all but single- or double-character substrings and all-numeric substrings and leave the rest alone? The string will never have regex metacharacters in it, just mixed alpha and numeric, all-alpha, or all-numeric. The colons can stay. 2. Is there an easy way to count the number of substrings (the chunks between colons)? 3. This one is probably a bit difficult. I don't need to have it, but it would save me lots of effort if I had it. Given two strings of the same form as in no. 1, is there a regular expression which can compare the two and return the number of substring positions which have exact matches? I.e., given string 1 = :L000:W000:M:M260:G607: and string 2 = :L001:W000:M:M261:M260: can match the substrings and their positions and return the result 2 in this case? The M260 substring is present in both but in different positions and shouldn't be counted as a match. Thanks in advance for your help! Scott Scott E. Robinson data SWAT Team UTC Onsite User Support RR-690 -- 281-654-5169 EMB-2813N -- 713-656-3629 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Print -strange behavior
--- Jose Luis Martinez [EMAIL PROTECTED] wrote: Hello Ovid This is the code that I am trying to run #!/usr/bin/perl my $a=Hello World; print $a; There is nothing wrong with this code. Thoughts: * what is the result of 'which perl'? Are you pointing to the same interpreter? (though this should not make a difference) * are your line endings wrong? * Try redirecting output to a file and opening it up in a hex editor. Again, I doubt that will reveal anything, but I'm at a loss to know what's going on without actually sitting down at your machine. Cheers, Ovid = Ovid on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problems matching filenames
I've made a small program that tries to get all the files from a directory that's full of files that they have the name format : pepe-1_DDMM.txt or pepe-2_DDMM.txt. First, I am just trying to get them and print the array created. Afterwards, when this works I'll do more things with the data in them included, but for now I can't get though with the first objective :-/ When I execute the program it makes NOTHING!!! At least, that's what it seems... I know its not a very good code, but it's my first one! :-D Can anybody give some advice about where's the bug? Thanks in advance. #!perl use strict; use warnings; my $program; my @filenames; opendir (FITXER,c:/documents and settings/administrador/escritorio/pepes) or die no es pot llegir el directori: $!\n; @noms = readdir (FITXER) or die no es poden agafar els noms dels fitxers \n; foreach $program (@noms) { if ($program =~ m/^pepe-1_(\d[8])\.txt$/) { ### do stuff, given a filename print $program \n; } elsif( $program =~ m/^pepe-2_(\d[8])\.txt$/) { ### do stuff, given a filename print $program stdout; } }; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems matching filenames
Papapep wrote: I've made a small program that tries to get all the files from a directory that's full of files that they have the name format : pepe-1_DDMM.txt or pepe-2_DDMM.txt. First, I am just trying to get them and print the array created. Afterwards, when this works I'll do more things with the data in them included, but for now I can't get though with the first objective :-/ When I execute the program it makes NOTHING!!! At least, that's what it seems... I know its not a very good code, but it's my first one! :-D We've all written naff code. Sometimes quite often! Welcome to Perl. Can anybody give some advice about where's the bug? Thanks in advance. #!perl use strict; use warnings; my $program; my @filenames; opendir (FITXER,c:/documents and settings/administrador/escritorio/pepes) or die no es pot llegir el directori: $!\n; Leave Perl to put its own \n on the end of the die string. Then it will also add the source line number being executed when it dies. @noms = readdir (FITXER) or die no es poden agafar els noms dels fitxers \n; foreach $program (@noms) You haven't declared @noms. This will fail in compilation with 'use strict' in effect. { if ($program =~ m/^pepe-1_(\d[8])\.txt$/) You need braces around the '8', not square brackets. Also you can search for both the pepe-1 and pep-2 files with if ($program =~ m/^pepe-[12]_(\d{8})\.txt$/) { ### do stuff, given a filename print $program \n; This will work, rpviding you have fixed the other errors. } elsif( $program =~ m/^pepe-2_(\d[8])\.txt$/) braces again! { ### do stuff, given a filename print $program stdout; This will try to read from the stdout filehandle and try to print each line to the filehandle specified by $program. Note that stdout is case=sensitive, and isn't the same as STDOUT, but either way it's not open for input and the read will fail. What you probably mean is print STDOUT $program; but STDOUT is selected by default anyway, so you may as well just use print $program\n; as you did before. I hope this helps. Come back if you need anything more. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename in windows doesn't work
From: Rosenstein, Leon [EMAIL PROTECTED] Currently the script reads: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; @filenames = readdir (DIR) or die Can't Hold Filenames \n; foreach $name (@filenames) {if ($name eq blah.dat) {rename ($name, blah.old) or die sorry couldnt complete task cause $! } }; C:\scriptzperl -w open4.pl sorry couldnt complete task cause No such file or directory at open4.pl line 7. The script tries to rename the blah.dat in the CURRENT WORKING DIRECTORY, not in c:\temp ! Use rename (C:/temp/$name, c:/temp/blah.old) HTH, Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-w and warnings.pm
Hello list, If I understand this right -w and warnings.pm do the same thing except :: - warnings.pm is new to Perl 5.6.0 - -w applies to the entire program and warnings.pm can be done block leveland stopped with 'no warnings;' So my questions is this. Does -w still work the same as it did with 5.6.0 and later? Is there a chance that it will become deprecated anytime soon? The reason being I am deploying a script that will need to run on lots of different servers and some will have old and some will have new versions of perl. I want have warnings on all of them without having different versions of my script or the need to change the script if they upgrade perl. So I figure -w will do me. Is there anything I'm missing or am I correct in my assumption? Thanks Dan
Re: Searching for the right regular expressions
Hi, Rob! Amazing how quickly you coded those up! 1.a. works great. 1.b. doesn't quite work yet. The revised version (my @wanted = $string =~ /\b\w\d*\b/ig;) seems to let everything pass through it. 1.c. - Sorry I wasn't clear. I need to keep the all-numeric substrings as well as keeping the single- and double-letter substrings. Your code kept the double-letter ones beautifully, though. Does the output have to go to an array? I can just reassemble it to a single string (either delimited by colons or single blanks) as you showed, but wondered if it can be skipped for greater efficiency. Thanks, Scott Scott E. Robinson SWAT Team UTC Onsite User Support RR-690 -- 281-654-5169 EMB-2813N -- 713-656-3629 Rob Dixon [EMAIL PROTECTED] To: [EMAIL PROTECTED] .co.uk cc: Subject: Re: Searching for the right regular expressions 03/24/03 10:08 AM Hi. Rading your post again, it looks like I kinda screwed up. Lets try again! Rob Dixon wrote: Hi Scott Scott E Robinson wrote: Dear Perl experts, I'm trying to find the right regular expressions to do some simple (?) string processing. Can anyone tell me how to do these? 1. Given a string consisting of substrings delimited by colons, such as :B520:L201:M:M260:8:G607:, my $string = ':B520:L201:M:M260:8:G607:'; how can I a. remove the single-character and all-numeric substrings (M and 8 in this example), leaving the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /[a-z]\w+/ig; print @wanted\n; output B520 L201 M260 G607 I think that's right, although it assumes that the values that aren't all-numeric start with an alpha. b. remove all but the single-character and all-numeric substrings and leave the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /\b\w\b/ig; print @wanted\n; output M 8 Right result, but fails to find '88'. Try: my @wanted = $string =~ /\b\w\d*\b/ig; c. remove all but single- or double-character substrings and all-numeric substrings and leave the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /\b[a-z]\w?\b/ig; print @wanted\n; output M This is right, I think. (Note that this won't find '8M', but your data doesn't look like that will come up.) That's more like it! Rob -- 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: Searching for the right regular expressions
Scott E Robinson wrote: Hi, Rob! Amazing how quickly you coded those up! 1.a. works great. 1.b. doesn't quite work yet. The revised version (my @wanted = $string =~ /\b\w\d*\b/ig;) seems to let everything pass through it. Sorry, I would say I'm having a bad day, but I'm not - I have no excuse! b. remove all but the single-character and all-numeric substrings and leave the rest alone? my @wanted = $string =~ /\b(\w|\d+)\b/ig; print @wanted\n; output M 8 1.c. - Sorry I wasn't clear. I need to keep the all-numeric substrings as well as keeping the single- and double-letter substrings. my $string = ':1:12:123:1234:A:AA:AAA::A1:A11:A111:'; my @wanted = $string =~ /\b(\w\w?|\d+)\b/ig; print @wanted\n; output 1 12 123 1234 A AA A1 Does the output have to go to an array? I can just reassemble it to a single string (either delimited by colons or single blanks) as you showed, but wondered if it can be skipped for greater efficiency. It has to go /via/ a list, but you can do it in one step without using an array like this: my $string = ':B520:L201:M:M260:8:G607:'; my $subset = join ':', '', $string =~ /\b(\w\w?|\d+)\b/ig, ''; print $subset; output :M:8: Is that any better? :-) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using Devel::ptkdb module
I have been using the Devel::ptkdb module on SunOS, which is a really fine tool. However, the text in the code pane is extremely small. perldoc has a list of environment variables which can be used to manipulate X resources, and I tried, setenv PTKDB_CODE_FONT 9x12 And then I ran the debugger, but the font did not change in the code pane. But, if I run an xterm with xterm -fn 9x12 the xterm is displayed with the correct font size. Has anyone been able to manipulate the font size using this module? If so, what did you do to change the font size? Thanks, deb PS: I'm on the digest of this list. So, I advance my apologies if you don't hear a response from me right away. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching for the right regular expressions
Rob, I found versions of 1.b. and 1.c. that seem to work, using the '|' operator. They're probably not the most elegant: Given a colon-delimited string such as my $string = ':B520:L201:M:MM:M260:8:88:G607:'; 1.b. Keep single-letter substrings and also any all-numeric substrings: my @wanted = $string =~ /\b(\w|\d*)\b/ig; 1.c. Keep only single- and double-letter substrings and also any all-numeric substrings: my @wanted = $string =~ /\b[a-z]\w?\b|\b[0-9]+\b/ig; I still wonder if the array is necessary. Thanks, Scott Scott E. Robinson SWAT Team UTC Onsite User Support RR-690 -- 281-654-5169 EMB-2813N -- 713-656-3629 - Forwarded by Scott E Robinson/U-Houston/ExxonMobil on 03/24/03 11:20 AM - Scott E Robinson To: Rob Dixon [EMAIL PROTECTED] cc: [EMAIL PROTECTED] 03/24/03 11:06 AMSubject: Re: Searching for the right regular expressions(Document link: Scott E Robinson) Hi, Rob! Amazing how quickly you coded those up! 1.a. works great. 1.b. doesn't quite work yet. The revised version (my @wanted = $string =~ /\b\w\d*\b/ig;) seems to let everything pass through it. 1.c. - Sorry I wasn't clear. I need to keep the all-numeric substrings as well as keeping the single- and double-letter substrings. Your code kept the double-letter ones beautifully, though. Does the output have to go to an array? I can just reassemble it to a single string (either delimited by colons or single blanks) as you showed, but wondered if it can be skipped for greater efficiency. Thanks, Scott Scott E. Robinson SWAT Team UTC Onsite User Support RR-690 -- 281-654-5169 EMB-2813N -- 713-656-3629 Rob Dixon [EMAIL PROTECTED] To: [EMAIL PROTECTED] .co.uk cc: Subject: Re: Searching for the right regular expressions 03/24/03 10:08 AM Hi. Rading your post again, it looks like I kinda screwed up. Lets try again! Rob Dixon wrote: Hi Scott Scott E Robinson wrote: Dear Perl experts, I'm trying to find the right regular expressions to do some simple (?) string processing. Can anyone tell me how to do these? 1. Given a string consisting of substrings delimited by colons, such as :B520:L201:M:M260:8:G607:, my $string = ':B520:L201:M:M260:8:G607:'; how can I a. remove the single-character and all-numeric substrings (M and 8 in this example), leaving the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /[a-z]\w+/ig; print @wanted\n; output B520 L201 M260 G607 I think that's right, although it assumes that the values that aren't all-numeric start with an alpha. b. remove all but the single-character and all-numeric substrings and leave the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /\b\w\b/ig; print @wanted\n; output M 8 Right result, but fails to find '88'. Try: my @wanted = $string =~ /\b\w\d*\b/ig; c. remove all but single- or double-character substrings and all-numeric substrings and leave the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /\b[a-z]\w?\b/ig; print @wanted\n; output M This is right, I think. (Note that this won't find '8M', but your data doesn't look like that will come up.) That's more like it! Rob --
Re: Using Print -strange behavior
On 2003-03-24 07:27:14 -0800, Ovid wrote: --- Jose Luis Martinez [EMAIL PROTECTED] wrote: Hello Ovid This is the code that I am trying to run #!/usr/bin/perl my $a=Hello World; print $a; There is nothing wrong with this code. Thoughts: * what is the result of 'which perl'? Are you pointing to the same interpreter? (though this should not make a difference) * are your line endings wrong? Try: #!/usr/bin/perl my $greeting=Hello World\n; print $greeting; With my shell prompt the \n in $greeting is necessary, else the output is eaten by the prompt. Hope this helps Morten -- OpenPGP: 0xF1360CA9 - 8CF5 32EE A5EC 36B2 4E3F ACDF 6D86 BEB3 F136 0CA9 Morten Liebach [EMAIL PROTECTED] - http://m.mongers.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching for the right regular expressions
Thanks, Rob! I just sent out my proposed solution for 1.b and 1.c, and they basically match yours. Makes me feel good. Thanks for the one-step way to write it, too. By the way, do you have any array-less way to do 2 or 3 in the original post? 2 was to count the number of colon-delimited substrings without using an array; 3 was to compare one string to another and count the number of colon-delimited substrings that match in the same positions. For example, these two strings: string1 = :L000:W000:M260:M:B297: string2 = :M260:W000:B601: would have only one match -- W000. The M260 is present in both, but not in the same position, a position being the order of the substrings within the main string. Thanks, Scott Scott E. Robinson SWAT Team UTC Onsite User Support RR-690 -- 281-654-5169 EMB-2813N -- 713-656-3629 Rob Dixon [EMAIL PROTECTED] To: [EMAIL PROTECTED] .co.uk cc: Subject: Re: Searching for the right regular expressions 03/24/03 11:23 AM Scott E Robinson wrote: Hi, Rob! Amazing how quickly you coded those up! 1.a. works great. 1.b. doesn't quite work yet. The revised version (my @wanted = $string =~ /\b\w\d*\b/ig;) seems to let everything pass through it. Sorry, I would say I'm having a bad day, but I'm not - I have no excuse! b. remove all but the single-character and all-numeric substrings and leave the rest alone? my @wanted = $string =~ /\b(\w|\d+)\b/ig; print @wanted\n; output M 8 1.c. - Sorry I wasn't clear. I need to keep the all-numeric substrings as well as keeping the single- and double-letter substrings. my $string = ':1:12:123:1234:A:AA:AAA::A1:A11:A111:'; my @wanted = $string =~ /\b(\w\w?|\d+)\b/ig; print @wanted\n; output 1 12 123 1234 A AA A1 Does the output have to go to an array? I can just reassemble it to a single string (either delimited by colons or single blanks) as you showed, but wondered if it can be skipped for greater efficiency. It has to go /via/ a list, but you can do it in one step without using an array like this: my $string = ':B520:L201:M:M260:8:G607:'; my $subset = join ':', '', $string =~ /\b(\w\w?|\d+)\b/ig, ''; print $subset; output :M:8: Is that any better? :-) Rob -- 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]
Net::Telnet -- Checking File Exists
How do you check if a file exists on a remote server using Net::Telnet ? I have tried: $testFile = /tmp/noFileExistsHere; $result = $t-cmd(test -f $testFile ; print $? ); $result = $t-cmd(test -f $testFile print 1 || print 0); $result = $t-cmd(if [ -f $testFile ] ;then print 1; else print 0; fi); and $result ALWAYS contains 1. The only way I can think of is: $result = $t-cmd(ls -l $testFile); then checking $result for an error message. Any better solutions? Jeff __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: -w and warnings.pm
Ok, let me simplify the question. Does the #!perl -w switch still work on Perl 5.6.0 and later? Thanks, Dan Hello list, If I understand this right -w and warnings.pm do the same thing except :: - warnings.pm is new to Perl 5.6.0 - -w applies to the entire program and warnings.pm can be done block leveland stopped with 'no warnings;' So my questions is this. Does -w still work the same as it did with 5.6.0 and later? Is there a chance that it will become deprecated anytime soon? The reason being I am deploying a script that will need to run on lots of different servers and some will have old and some will have new versions of perl. I want have warnings on all of them without having different versions of my script or the need to change the script if they upgrade perl. So I figure -w will do me. Is there anything I'm missing or am I correct in my assumption? Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems matching filenames
Rob Dixon wrote: This will try to read from the stdout filehandle and try to print each line to the filehandle specified by $program. Note that stdout is case=sensitive, and isn't the same as STDOUT, but either way it's not open for input and the read will fail. Perl originally used the lower case filehandles stdin, stdout and stderr and they are still supported in current versions although they will produce warnings. $ perl -le' print STDOUT test STDOUT; print stdout test stdout; print STDERR test STDERR; print stderr test stderr; print NONE test NONE; print none test none; ' test STDOUT test stdout test STDERR test stderr $ perl -Mwarnings -Mstrict -le' print STDOUT test STDOUT; print stdout test stdout; print STDERR test STDERR; print stderr test stderr; print NONE test NONE; print none test none; ' Unquoted string stdout may clash with future reserved word at -e line 3. Unquoted string stderr may clash with future reserved word at -e line 5. Unquoted string none may clash with future reserved word at -e line 7. Name main::NONE used only once: possible typo at -e line 6. Name main::none used only once: possible typo at -e line 7. test STDOUT test stdout test STDERR test stderr Filehandle main::NONE never opened at -e line 6. Filehandle main::none never opened at -e line 7. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: thanks for the help last time, could you help me again
Hi Dan Howdy, please post Perl questions to the list so we can all enjoy. I have this script that is not working as it should be. this is what it is supposed to be doing, take images from a directory (images are coming from camera) and renames them with the date and time of image. then insert some meta information into MySQL. what the script is supposed to be doing is to always keep looking and whenever it finds images to perform the change and insert. the output is as follow: it only does the process once. i would appreciate any help. cheers, Mel --- renaming /home/httpd/htdocs/image.jpg to /home/me/images/2003_03_24_18_14_12.jpg adding /home/me/images/2003_03_24_18_14_12.jpg to database [EMAIL PROTECTED] cgi-bin]# size is 196378 modified is 20030324181412 filename is 2003_03_24_18_14_12.jpg Use of uninitialized value in concatenation (.) or string at renamerr.pl This probably means that you are using a variable that you didn't declare with my first. Is that the problem? Now that we have what is supposed to be doing please tell us what it is/isn't Doing the way you think it should. line 99 . Failed to get the info $file is: at renamerr.pl line 99. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
The Loop in this script is driving me crazy.
Hi, The problem has been highlighted to me by a great person in this list, but i just cant solve it. I have this script that is not working as it should be. this is what it is supposed to be doing, take images from a directory (images are coming from camera) and renames them with the date and time of image. then insert some meta information into MySQL. what the script is supposed to be doing is to always keep looking and whenever it finds images to perform the change and insert. the output is as follow: it only does the process once. i would appreciate any help. cheers, Mel --- renaming /home/httpd/htdocs/image.jpg to /home/me/images/2003_03_24_18_14_12.jpg adding /home/me/images/2003_03_24_18_14_12.jpg to database [EMAIL PROTECTED] cgi-bin]# size is 196378 modified is 20030324181412 filename is 2003_03_24_18_14_12.jpg Use of uninitialized value in concatenation (.) or string at renamerr.pl line 99 . Failed to get the info $file is: at renamerr.pl line 99. - The script is as follow: #!/usr/bin/perl use strict; use warnings; use DBI; use Date::Manip; =head1 NAME # renamer - renames files received by ftp, moving them to a new directory =head1 SYNOPSIS nohup ./renamer image /home/httpd/htdocs /home/me/images jpg renamer.process =head1 DESCRIPTION #The above instructs renamer to look for files called image.jpg in /home/httpd/htdocs.It checks once per minute for such a file to appear. If it sees a #readable file called /home/httpd/htdocs.jpg it moves it to/home/httpd/htdocs/image.200302251530.jpg where the number is a #time stamp with year (four digits), month, day of the month, hour (in24 mode), and minute. #Read the bugs section closely. =head1 BUGS #The original and new directories must be on the same file system.The program probably does not work on windows systems. #The daemon behavior is weak.Not much testing has been done, so the script may have other problems. =cut my $usage = EOUSAGE; usage: $0 initial_name original_dir new_dir suffix lockfile example: $0 pic /home/httpd/htdocs /home/me/images jpg /home/me/renamer.process EOUSAGE my $check_file = shift or die $usage; my $original_dir = shift or die $usage; my $new_dir = shift or die $usage; my $suffix = shift or die $usage; my $lockfile = shift or die $usage; ## # If you put it into the cron, comment out between the START and END BLOCK, and uncomment the section below it so you don't get multiple copies running. Also, comment out the # lockfile bits above. #START BLOCK exit if (fork()); while (-e $lockfile) { process($check_file) if (-r $original_dir/$check_file.$suffix); infoinsert(); sleep 30; } #END BLOCK ## # # process($check_file) if (-r $original_dir/$check_file.$suffix); # ## sub process { my $file = shift; my @st = (stat($original_dir/$file.$suffix)); my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime($st[10]); $Year += 1900; $Month++; my $stamp = sprintf %4d_%02d_%02d_%02d_%02d_%02d, $Year, $Month, $Day, $Hour, $Minute, $Second; print renaming $original_dir/$file.$suffix to $new_dir/$stamp.$suffix\n; rename $original_dir/$file.$suffix, $new_dir/$stamp.$suffix or warn couldn't rename file: $! $file to $new_dir/$file.$stamp.$suffix\n; print adding $new_dir/$stamp.$suffix to database\n; my $single_string = $new_dir . '/' . $stamp . '.' . $suffix; infoinsert ($single_string); } # # Connect to Database Named cctvimages on the localhost with the root user # $dbh=DBI-connect(DBI:mysql;$database, $user, $password); # and insert info about the file given as the argument $_[0]; # sub infoinsert { my ($file) = @_; dieFailed to get the info\n\$file is: $file if not defined $file; my $dbh = DBI-connect(DBI:mysql:dbname=cctvimages;host=localhost,root, **, {'RaiseError' = 1}); my $size; my $mtime; my $secs; ($size, $secs) = (stat ($file))[7,9]; $mtime = ParseDateString(epoch $secs); # even after conversion ':' is used to seperate hh and mn and ss $mtime =~ s/://g; # the above swaps out the ':' for nothing $file =~ s/\/home\/me\/images\///; # the above strips path printsize is $size\nmodified is $mtime\nfilename is $file\n; my $rows_affected = $dbh-do(INSERT INTO imageinfo VALUES(null, '$file', '$size', '$mtime')) or die Do Fails: $DBI::errstr\n; my $sql = SELECT * FROM imageinfo; my $sth = $dbh-prepare($sql); $sth-execute or dieExecute fails: $DBI::errstr\n; $sth-finish; $dbh-disconnect; } _ Surf together with new Shared Browsing http://join.msn.com/?page=features/browsepgmarket=en-gbXAPID=74DI=1059 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
counting fork process, again
Helloe everyone, I was wondering is someone can help me out with an issue with forking. I am trying to fork 8 process at a time. Here is what I have: code snippet #!/usr/bin/perl use strict; use warnings; use lib .; use BACKUP; #my own module use POSIX :sys_wait_h; my( $MAX_CHILDREN ) = 8; my( $CHILD_PIDS ) = 0; my( $maxtries ) = 7; my( $failure ) = 0; # there are actually 100 hostIds. but you should get the point.. my( @hostIds ) = 10.10.10.1, 10.10.10.2, 10.10.10.3 ,10.10.10.4; $SIG{CHLD} = \CHILD_COUNT($CHILD_PIDS); FORK: { HOSTID: foreach my $hostId ( @hostIds ) { redo HOSTID if $CHILD_PIDS = $MAX_CHILDREN; if( my $pid = fork ) { $CHILD_PIDS++; #Add the children up until we hit the max next; }elsif (defined $pid) { # In here I do some stuff with each $hostID. # To make the code easier to read, I made a module that # has a bunch of subroutines in it. #There are basically 2 subroutines that I call for each # hostID. 1 grabs the quota for each user on the hostId, #The other tars and copies the user where the script # is. I eval my connection and if some fails I # go on to the next. ex. until ( (BACKUP-QuotaIt( $hostId ) or ( $failures == $maxtries ) ) ) { $failures++; if ( $failures == $maxtries ) { my( $subject ) = Hey, WTF is up with $hosId; my( $message ) = $0 failed to connect to $hostID.; BACKUP-MailIt( $subject, $message, $daily ); #go to the next hostid next HOSTID2; } #if statememt } #until statement }elsif($! =~ /No more process/){ sleep 15; redo; #do over. }else{ # this is just a mail routine that mails be that I #can't fork my( $subject ) = Failed to fork any children; my( $message ) = $0 failed to fork anymore children. BACKUP-MailIt( $subject, $message, $daily ); die; } } # foreach loop ends } # this is the FORK sub CHILD_COUNT { my $child_pids = @_; my $child = waitpid(-1,WNOHANG); while ($child != -1 ($child_pids 0 )) { $child_pids--; $child = waitpid(-1,WNOHANG); } } end of code snippet Just typing this I realized that if I can't fork then I probably won't be able to mail myself a notification. So I gotta change that else statement with the mail notification. Anyways, the issues I am having are two fold. The first I get this warning: Not a subroutine reference at ./script.pl line 331 which is: redo HOSTID2 if $CHILD_PIDS = $MAX_CHILDREN; The second is a bigger issue. I also fork in the home made perl module for each user of the HostId I am doing. nothing crazy, just. #--# foreach $user (@users) { my( $pid ) = fork (); die Cannot fork: $! unless defined( $pid ); if ( $pid == 0 ) { #do tarring of user exit 0; } waitpid($pid,0); } #---# Here I get the error: Not a subroutine reference at BACKUP.pm line 195. which is: waitpid($pid,0); I know this is very confusing. And I might not even be posting to the right list. But I am so frustrated with trying to get this thing to work. It seems as if I have searched everywhere for examples of limiting the number of forked processes, then being able to fork with in a fork. I originally was using Parallel::ForkManager. But I found that if I set the max_processes to 8 it will start eight but will not contiue until all eight were done, then only do one at a time. That's when I decided to go the POSIX route and use fork.. But just can't get it working. I think setting the SIG{CHLD} is messing things up. BUt I am not sure. Sorry for being so drawn out. Please feel free to tear me/my code up. I am new and would really like to know how to do this. Don't worry I can take criticism pretty well... lol Thanks in advance, Chad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::Telnet -- Checking File Exists
Jeff Westman wrote: How do you check if a file exists on a remote server using Net::Telnet ? I have tried: $testFile = /tmp/noFileExistsHere; $result = $t-cmd(test -f $testFile ; print $? ); $result = $t-cmd(test -f $testFile print 1 || print 0); $result = $t-cmd(if [ -f $testFile ] ;then print 1; else print 0; fi); and $result ALWAYS contains 1. The only way I can think of is: $result = $t-cmd(ls -l $testFile); then checking $result for an error message. Any better solutions? test like most command line tools returns zero for true and non-zero for false so try this: my $result = ! $t-cmd( test -f $testFile ; echo $? ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
\ vs / vs %
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi everyone, I am pretty new to perl so I assume you guys and girls will starting getting to know me really well. I have a one line snippet of code that I am trying to run. The system is win2k sp3. I am trying to run the expand command and pass to it some arguments that contain system variables. The code: #Ok we have renamed the files now we need to run the expand command: system(expand perfc009.DA_ %windir%\\system32\\perfc009.DAT) die no $!; and when I run I get it: C:\Perfperl -w maintest.pl.txt Microsoft (R) File Expansion Utility Version 5.00.2134.1 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. Expanding perfc009.da_ to %windir%\system32\perfc009.dat. Can't open output file: %windir%\system32\perfc009.dat. no at maintest.pl.txt line 5. My first question is; did I do the right thing by putting a \ before the \ in the path? My second question is whether or not the % sign is messing things up? Finally I am wondering how best to solve this? DO you think hard coding the actual path (instead of using %windir% would help? Thx again! Leon -BEGIN PGP SIGNATURE- Version: PGP 8.0 iQA/AwUBPn9VR0k2S2y0JhBMEQJUewCfRsOIXFTIzWI1Unpo85aw2PWExRgAnRWO uxuuRslvggSiFyE3bbJYHj7u =9xua -END PGP SIGNATURE- INDEPENDENCE COMMUNITY BANK CONFIDENTIALITY NOTICE: This message (and any attachment) is confidential and intended for the sole use of the individual or entity to which it is addressed. If you are not the intended recipient, you must not review, retransmit, convert to hard-copy, copy, use or disseminate this email or any of its attachments. If you received this email in error, please notify the sender immediately and delete it. This notice is automatically appended to all Internet email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: \ vs / vs %
system(expand perfc009.DA_ %windir%\\system32\\perfc009.DAT) Try this instead: system(expand perfc009.DA_ $ENV{'windir'}\\system32\\perfc009.DAT); Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::Telnet -- Checking File Exists
--- Jeff Westman [EMAIL PROTECTED] wrote: my $result = ! $t-cmd( test -f $testFile ; echo $? ); Doesnt work. (makes no difference) In my question below, I should state that it always returns '1' irregardless if the file exists or not --- John W. Krahn [EMAIL PROTECTED] wrote: Jeff Westman wrote: How do you check if a file exists on a remote server using Net::Telnet ? I have tried: $testFile = /tmp/noFileExistsHere; $result = $t-cmd(test -f $testFile ; print $? ); $result = $t-cmd(test -f $testFile print 1 || print 0); $result = $t-cmd(if [ -f $testFile ] ;then print 1; else print 0; fi); and $result ALWAYS contains 1. The only way I can think of is: $result = $t-cmd(ls -l $testFile); then checking $result for an error message. Any better solutions? test like most command line tools returns zero for true and non-zero for false so try this: my $result = ! $t-cmd( test -f $testFile ; echo $? ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: -w and warnings.pm
From: Dan Muey [EMAIL PROTECTED] Ok, let me simplify the question. Does the #!perl -w switch still work on Perl 5.6.0 and later? Yes. No need to worry. Thanks for the peace of mind! Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: counting fork process, again
From: chad kellerman [EMAIL PROTECTED] Helloe everyone, I was wondering is someone can help me out with an issue with forking. I am trying to fork 8 process at a time. I did not read the previous thread. Did you consider Parallel::ForkManager or Win32::ProcFarm? (Both on CPAN) Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: \ vs / vs %
From: Rosenstein, Leon [EMAIL PROTECTED] The code: #Ok we have renamed the files now we need to run the expand command: system(expand perfc009.DA_ %windir%\\system32\\perfc009.DAT) die no $!; and when I run I get it: C:\Perfperl -w maintest.pl.txt Microsoft (R) File Expansion Utility Version 5.00.2134.1 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. Expanding perfc009.da_ to %windir%\system32\perfc009.dat. Can't open output file: %windir%\system32\perfc009.dat. no at maintest.pl.txt line 5. My first question is; did I do the right thing by putting a \ before the \ in the path? Yes. My second question is whether or not the % sign is messing things up? It seems the %variable% was not espanded to the path. What version or Perl are you using? (run perl -v to find out). It's safer to let Perl expand the variable: system(expand perfc009.DA_ $ENV{windir}\\system32\\perfc009.DAT) HTH, Jenda P.S.: You should use something better than Notepad to edit your scripts. And save them with .pl extension, not with .pl.txt. See eg. http://www.scintilla.org/SciTE.html = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: counting fork process, again
Jenda, Actually, that's what I started with. But here is what I found. If I set the $max_processes to 8 in Parallel::ForkManager. IT would indeed spawn off 8 children. But as the children finished died new ones did not take their place. Not until all 8 children were finished, did a new child become present. And that was only 1 child at a time. Not 8. THat 's why I decided to go the POSIX route. I di not use Win32::ProcFarm because I am only working on a *nix network. Thanks, --chad On Monday 24 March 2003 02:19 pm, Jenda Krynicky wrote: From: chad kellerman [EMAIL PROTECTED] Helloe everyone, I was wondering is someone can help me out with an issue with forking. I am trying to fork 8 process at a time. I did not read the previous thread. Did you consider Parallel::ForkManager or Win32::ProcFarm? (Both on CPAN) Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename in windows doesn't work
From: Rob Dixon [EMAIL PROTECTED] Leon Rosenstein [EMAIL PROTECTED] wrote: I am having some problems with a script. Currently the script reads: opendir (DIR, c:/temp) or die Cant Open Temp Buddy Boy! \n; Don't put \n on the end of a die string, otherwise the Perl interpreter won't tell you the line number of the failure. Well it's good to know you'll get the line number and source file name if you omit the newline, but ... most often you do not want it there. What would you think of a program that responds to you with Cannot find file Foo.txt at script.pl line 26. ? Looks like the programm crashed, not that it just compains that the user entered an incorrect filename. If it's a message that's supposed to be seen by lusers you most probably do not want the source info appended. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: -w and warnings.pm
From: Dan Muey [EMAIL PROTECTED] Ok, let me simplify the question. Does the #!perl -w switch still work on Perl 5.6.0 and later? Yes. No need to worry. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::Telnet -- Checking File Exists -SOLUTION
Perseverance pays off. Solution to checking if a file exists is to store result in a variable before it gets converted: $result = sprintf(%s, $t-cmd(test -f $testFile print 1 || print 0)); Note: None of the following worked: $result = ! $t-cmd( test -f $testFile ; echo $? ); $result = $t-cmd(test -f $testFile ; print $? ); $result = $t-cmd(test -f $testFile print 1 || print 0); $result = $t-cmd(if [ -f $testFile ] ;then print 1; else print 0); (this still doesn't make sense to me) -JW __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: counting fork process, again
From: chad kellerman [EMAIL PROTECTED] Jenda, Actually, that's what I started with. But here is what I found. If I set the $max_processes to 8 in Parallel::ForkManager. IT would indeed spawn off 8 children. But as the children finished died new ones did not take their place. Not until all 8 children were finished, did a new child become present. And that was only 1 child at a time. Not 8. THat 's why I decided to go the POSIX route. I see. That looks like a bug to me. Did you contact the Parallel::ForkManager's author about this? I di not use Win32::ProcFarm because I am only working on a *nix network. OK, I did not know. I'm only working under Windows. So I guess I would not be of much help for you. What would work for me probably would not for you. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1) Automated FTP 2) txt to html 3) pstools vs WMI
Pradeep Goel wrote: 2) Also if somebody what I can do to make a page html instead of txt or doc - keeping up the format ( need not be exact format but it should not just be a messed up one). when i rename from .doc to .html or use copy command ( i.e. on windows machine) the format goes off completely - what left is contiguous words that's all ?. If you wish to produce web content, you should learn the HTML language on which it is based. White space is ignored in that protocol. Any space fromatting intended for the output must be expressed through html tags. HTML does have a feature much like the perl heredoc in the pre tag. This tag directs the client to display all text before the ending /pre tag as spaced in the source. You can start learning html at any time simply by selecting View|Page Source from the menu of your browser, and comparing the source code to the displayed effects. The best source for information on writing for the web would be an HTML authoring list. One Perl alternative is to use the CGI module to generate html dynamically. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Best way to stop array interpolation.
Bakken, Luke wrote: Here's a quickie: I need to create a hash index out of a string that looks like this: loans:a_foo[0] If I build the index like this: $rec-{loans:a_$fld[$i]} = $tmp{$fld} || ''; perl thinks that $fld[$i] is an array element, which it isn't. Here are two solutions I found: $rec-{loans:a_$fld . [$i]} = $tmp{$fld} || ''; $rec-{loans:a_$fld\[$i]} = $tmp{$fld} || ''; Are there any other ways? Just curious. loans:a_${fld}[$i] also works. I like your second version above best. $ perl -MO=Deparse,-q -e 'a_${fld}[$i]' 'a_' . $fld . '[' . $i . ']'; $ perl -MO=Deparse,-q -e 'a_$fld\[$i]' 'a_' . $fld . '[' . $i . ']'; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Best way to stop array interpolation.
Here's a quickie: I need to create a hash index out of a string that looks like this: loans:a_foo[0] If I build the index like this: $rec-{loans:a_$fld[$i]} = $tmp{$fld} || ''; perl thinks that $fld[$i] is an array element, which it isn't. Here are two solutions I found: $rec-{loans:a_$fld . [$i]} = $tmp{$fld} || ''; $rec-{loans:a_$fld\[$i]} = $tmp{$fld} || ''; Are there any other ways? Just curious. Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Devel::ptkdb module
Jeff Westman [EMAIL PROTECTED] had this to say, Have you tried exporting PTKDB_CODE_FONT ? Not really - I should have said that I use tcsh, and environmental variables take effect immediately... Thanks for the response, though. deb -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename in windows doesn't work
Jenda Krynicky wrote: From: Rob Dixon [EMAIL PROTECTED] Don't put \n on the end of a die string, otherwise the Perl interpreter won't tell you the line number of the failure. Well it's good to know you'll get the line number and source file name if you omit the newline, but ... most often you do not want it there. What would you think of a program that responds to you with Cannot find file Foo.txt at script.pl line 26. ? Looks like the programm crashed, not that it just compains that the user entered an incorrect filename. If it's a message that's supposed to be seen by lusers you most probably do not want the source info appended. Jenda, surely you appreciate that this is not a production program? Even if it were ever to be one, which I doubt, it is at present being debugged of the most basic problems. At this stage the cosmetic appearance of a warning message cannot surely be more important than how much it assists the development process? I would concede that I should have also pointed out that the $! diagnostic should have been included, but I consider line numbers on die messages to be as important as enabling warnings during development. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Best way to stop array interpolation.
Here are two solutions I found: $rec-{loans:a_$fld . [$i]} = $tmp{$fld} || ''; $rec-{loans:a_$fld\[$i]} = $tmp{$fld} || ''; Are there any other ways? Just curious. loans:a_${fld}[$i] also works. I like your second version above best. $ perl -MO=Deparse,-q -e 'a_${fld}[$i]' 'a_' . $fld . '[' . $i . ']'; $ perl -MO=Deparse,-q -e 'a_$fld\[$i]' 'a_' . $fld . '[' . $i . ']'; Hmm you know that was the first thing I tried, but I always get this error, indicating it's still looking for @fld: I also have use strict on. C:\tmpperl testadr Global symbol @fld requires explicit package name at testadr line 37. Global symbol @fld requires explicit package name at testadr line 43. BEGIN not safe after errors--compilation aborted at testadr line 48. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Best way to stop array interpolation.
Bakken, Luke wrote: Here are two solutions I found: $rec-{loans:a_$fld . [$i]} = $tmp{$fld} || ''; $rec-{loans:a_$fld\[$i]} = $tmp{$fld} || ''; Are there any other ways? Just curious. loans:a_${fld}[$i] also works. I like your second version above best. $ perl -MO=Deparse,-q -e 'a_${fld}[$i]' 'a_' . $fld . '[' . $i . ']'; $ perl -MO=Deparse,-q -e 'a_$fld\[$i]' 'a_' . $fld . '[' . $i . ']'; Hmm you know that was the first thing I tried, but I always get this error, indicating it's still looking for @fld: I also have use strict on. C:\tmpperl testadr Global symbol @fld requires explicit package name at testadr line 37. Global symbol @fld requires explicit package name at testadr line 43. BEGIN not safe after errors--compilation aborted at testadr line 48. You're right. I guess what I wrote is a no-no. Writing something like ${fld}foo is like $fld . foo But the opening square bracket seems to cause problems with strict turned on. Maybe somebody smarter than me (shouldn't be hard to find!) can explain further. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Iteration Question
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi again everyone, Again newbie here so go easy In a script I have a section that looks like this #Finally we have to load all extensible counters system(lodctr faxperf.ini) or die sorry couldn't do $!; system(lodctr dnsperf.ini) or die sorry couldn't do $!; system(lodctr esentperf.ini) or die sorry couldn't do $!; system(lodctr iasperf.ini) or die sorry couldn't do $! ; system(lodctr dnsperf.ini) or die sorry couldn't do $!; system(lodctr msdtcprf.ini) or die sorry couldn't do $!; system(lodctr ntdsctrs.ini) or die sorry couldn't do $!; system(lodctr ntfrsrep.ini) or die sorry couldn't do $!; system(lodctr perfci.ini) or die sorry couldn't do $!; system(lodctr perffilt.ini) or die sorry couldn't do $!; system(lodctr perfwci.ini) or die sorry couldn't do $!; system(lodctr pschdperf.ini) or die sorry couldn't do $!; system(lodctr rasctrs.ini) or die sorry couldn't do $!; system(lodctr rsvp.ini) or die sorry couldnt do $!; print all done; Sometimes one of the commands fail for a reason I am not sure of (it will fail at line 29 but when I rerun the script it will fail at 35 then it will fail at 40 then it wont fail at all. I also notice that when I actually manually enter the commands through the command line it sometimes doesnt take either. Dumb question but does anyone have a clue how I could write a loop to loop through this and rerun it if it doenst complete. I was thinking of writing a loop using until. Something like until we say all done keep running the script. Since i am new to programming all together (first language and all) it is sometimes hard to get into the mentality of a programmer. Thanks again this list has been a lifesaver today I appreciate all the help and encrouragment, Cheers, Leon -BEGIN PGP SIGNATURE- Version: PGP 8.0 iQA/AwUBPn+Bb0k2S2y0JhBMEQKgMgCfV5Z01be2LhnkpOemJ1Heb4DF6NoAoOk4 XQjXklcaqO13EH4IxDmv9fjV =5/se -END PGP SIGNATURE- INDEPENDENCE COMMUNITY BANK CONFIDENTIALITY NOTICE: This message (and any attachment) is confidential and intended for the sole use of the individual or entity to which it is addressed. If you are not the intended recipient, you must not review, retransmit, convert to hard-copy, copy, use or disseminate this email or any of its attachments. If you received this email in error, please notify the sender immediately and delete it. This notice is automatically appended to all Internet email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
A Solution to: Using Devel::ptkdb module
I have found a solution. If I give PTKDB_CODE_FONT env variable a full font name, instead of just 9x12, it happily agrees to do my bidding. Don't know why it works this way, but it does. I'd have to dive into the code to find out, I'm sure. So, here's what I did, setenv PTKDB_CODE_FONT -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 This is not equivalent to 9x15, but that's okay, because it looks just fine. Thanks, deb I have been using the Devel::ptkdb module on SunOS, which is a really fine tool. However, the text in the code pane is extremely small. perldoc has a list of environment variables which can be used to manipulate X resources, and I tried, setenv PTKDB_CODE_FONT 9x12 And then I ran the debugger, but the font did not change in the code pane. But, if I run an xterm with xterm -fn 9x12 the xterm is displayed with the correct font size. Has anyone been able to manipulate the font size using this module? If so, what did you do to change the font size? Thanks, deb PS: I'm on the digest of this list. So, I advance my apologies if you don't hear a response from me right away. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- There are 010 types of people in the world: those who understand binary, and those who don't. ô¿ô 111,111,111 x 111,111,111 = 12,345,678,987,654,321 (decimal) ~ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename in windows doesn't work
From: Rob Dixon [EMAIL PROTECTED] Jenda Krynicky wrote: From: Rob Dixon [EMAIL PROTECTED] Don't put \n on the end of a die string, otherwise the Perl interpreter won't tell you the line number of the failure. Well it's good to know you'll get the line number and source file name if you omit the newline, but ... most often you do not want it there. What would you think of a program that responds to you with Cannot find file Foo.txt at script.pl line 26. ? Looks like the programm crashed, not that it just compains that the user entered an incorrect filename. If it's a message that's supposed to be seen by lusers you most probably do not want the source info appended. Jenda, surely you appreciate that this is not a production program? Even if it were ever to be one, which I doubt, it is at present being debugged of the most basic problems. At this stage the cosmetic appearance of a warning message cannot surely be more important than how much it assists the development process? If the program is fairly short then it's very likely that the message itself is enough to find out where is it printed. But of course in this case it's not really important. I still tend to NOT let Perl include the line number if I intend the message to get printed to the user. Even during development. I'd definitely forget to add the \n before the code gets to production. Besides we all know the development never ends. But this is very subjective :-) Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: counting fork process, again
Chad Kellerman wrote: I know this is very confusing. And I might not even be posting to the right list. But I am so frustrated with trying to get this thing to work. It seems as if I have searched everywhere for examples of limiting the number of forked processes, then being able to fork with in a fork. I originally was using Parallel::ForkManager. But I found that if I set the max_processes to 8 it will start eight but will not contiue until all eight were done, then only do one at a time. the following probably does what you want. it creates 8 child processes to begin with and as those child process dies, it creates more. you will always have 8 child processes at a time: #!/usr/bin/perl -w use strict; use POSIX ':sys_wait_h'; my $child = 0; my $pid = 0; sub more_child{ $pid = fork; die(fork failed\n) unless(defined $pid); if($pid){ print ++$child, child ($pid)\n; }else{ sleep(1) for(1..3); exit; } } $SIG{CHLD} = sub { while((my $c=waitpid(-1,WNOHANG)) 0){ print $c finished\n; --$child; more_child} }; while(1){ for(1..8){ more_child; while($child == 8){select(*I,*J,*K,0.5)} } } __END__ if you check the process with ps or top, you will see there are always 9 processes at a time (1 parent + 8 children). in my linux box, it prints: Name main::K used only once: possible typo at ./tmp.pl line 60. Name main::J used only once: possible typo at ./tmp.pl line 60. Name main::I used only once: possible typo at ./tmp.pl line 60. 1 child (9829) 2 child (9830) 3 child (9831) 4 child (9832) 5 child (9833) 6 child (9834) 7 child (9835) 8 child (9836) 9830 finished 9836 finished 7 child (9838) 9835 finished 7 child (9839) 9834 finished 7 child (9840) 9833 finished 7 child (9841) ... etc the first 8 lines are the initial 8 children and the rest are those children created to replace the dead ones. the warnings are coming from select which aren't really relevant in this example. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: OLDB - ODBC
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 4:58 PM To: [EMAIL PROTECTED] Subject: OLDB - ODBC Does this belong in the DBI list? Sorry if the answer is yes. * Hi, We have a problem. We run Perl for Window NT. We use Perl to read ASCII Files, and write the information to a Database. Some of these fields are longer than 32,000 characters long. We just had one that was 86,000 characters long. The problem we have is that our driver is limited. It can't handle 86,000 characters. We needed to trim the length to 32,000 because we often had ASCII characters that were bigger than the normal size. We settled on 32,000. But now the department wants to get the whole record. The database can definitely hold that big of a variable. The problem is getting there with the limits of the driver that we are using. ** ** Here is a piece of the code of opening the driver. use Win32::Registry; my $Register = Software\\Sparq\\CLDSN_DEV; my $RegType, $RegValue, $RegKey, $value; my %values; $HKEY_LOCAL_MACHINE-Open($Register,$hkey)|| die $!; $hkey-GetValues(\%values); foreach $value (keys(%values)) { $RegType= $values{$value}-[1]; $RegValue = $values{$value}-[2]; $RegKey = $values{$value}-[0]; if($RegKey eq Name) { $Database=$RegValue; $FullDatabase = dbi:ODBC:$Database; } } $hkey-Close(); * The program with ODBC well and has been working for over a year. This issue has just come up. Is there an extension in ODBC that will be able to handle 200,000 bytes in one shot. Or perhaps another extension that is similar to OLDB? The Databse is: Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production PL/SQL Release 8.1.5.0.0 - Production TNS for 32-bit Windows: Version 8.1.5.0.0 - Production Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FW: OLDB - ODBC
On Mon, 24 Mar 2003 17:12:39 +0100 NYIMI Jose (BMB) [EMAIL PROTECTED] wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 4:58 PM To: [EMAIL PROTECTED] Subject: OLDB - ODBC Does this belong in the DBI list? Sorry if the answer is yes. No reason not. We have a problem. We run Perl for Window NT. We use Perl to read ASCII Files, and write the information to a Database. Some of these fields are longer than 32,000 characters long. We just had one that was 86,000 characters long. The problem we have is that our driver is limited. It can't handle 86,000 characters. We needed to trim the length to 32,000 because we often had ASCII characters that were bigger than the normal size. We settled on 32,000. But now the department wants to get the whole record. The database can definitely hold that big of a variable. The problem is getting there with the limits of the driver that we are using. The program with ODBC well and has been working for over a year. This issue has just come up. Is there an extension in ODBC that will be able to handle 200,000 bytes in one shot. Or perhaps another extension that is similar to OLDB? The Databse is: Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production PL/SQL Release 8.1.5.0.0 - Production TNS for 32-bit Windows: Version 8.1.5.0.0 - Production If it's an Oracle database, is there a reason you can't use DBD::Oracle? You should be able to insert at least that much into LONGs and CLOBs using placeholders under DBD::Oracle. You might still be able to do it with ODBC if you use placeholders and bind_param( ..., DBI::SQL_LONGVARCHAR ). Look at Handling BLOB / LONG / Memo Fields in the DBI manual. -- Mac :}) ** I normally forward private questions to the appropriate mail list. ** Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: to clean and copy
Adriano Allora wrote: Hi to all, Hello, my input = a directory in which I stored a certain amount of text files downloaded by some newsgroups; my desired_process = to clean all the files and copy them all in another directory; my desired_output = another directory in which there are all cleaned files; my problem = my script doesn't run (I suppose: there's no output and top command line says that perl does not use the processor); my request = where I mistake? THE SCRIPT #!/usr/bin/perl -w use strict; my $testo; my $txt; @ARGV = original_ones/*.txt; while(){ tr/\015\012/\n/s; tr/\=\\*\^\_\-\+\' //s; The only character you need to backslash is '-': tr/=*^_\-+' //s; Or not, if it is at the beginning or end of the list: tr/-=*^_+' //s; That is the same as: tr/-=*^_+' /-=*^_+' /s; Which replaces multiple contiguous '-' with a single '-' AND multiple contiguous '=' with a single '=' AND multiple contiguous '' with a single '' AND etc. Is that what you want? s/Newsgoups: it\..+|Subject: .+|Date: .+|Message-ID: .+|References: .+|Date: .+//g; Your regular expression is removing every thing up to but not including the newline at the end. Do you want to keep the blank line or remove the whole line? Also, the regular expression is not anchored so the literal strings will match if they are anywhere in the line. Remove whole line: $_ = '' if /^(?:Newsgoups: it\.|(?:Subject:|Date:|Message-ID:|References:) )/; Leave the newline at the end: $_ = \n if /^(?:Newsgoups: it\.|(?:Subject:|Date:|Message-ID:|References:) )/; s/(\w\')/$1 /g; $txt .=$_; if ( eof ) { $txt =~ s/(http:\/\/)?(\w){3,}(\.(\w(\-)?)+)+\.(\w){2,3}((\/)(\w)+((\.)(\w){1,5})*((\?)(\w){1,32}(=)(\w){1,32})*)*/ URL /g; You are using a LOT of capturing parenthesis which means the regex is doing extra work. Use non-capturing parenthesis instead. $txt =~ s!(?:http://)?\w{3,}(?:\.(?:\w-?)+)+\.\w{2,3}(?:/\w+(?:\.\w{1,5})*(?:\?\w{1,32}=\w{1,32})*)*! URL !g; $txt =~ s/[0-9]+/ /g; perl provides the \d character class which is the same as [0-9]. $txt =~ s/\d+/ /g; Or you could use tr///: $txt =~ tr/0-9/ /s; $txt =~ tr/\n\r\f\t //s; That is the same as: $txt =~ tr/\n\r\f\t /\n\r\f\t /s; Which replaces multiple contiguous \n with a single \n AND multiple contiguous \r with a single \r AND multiple contiguous \f with a single \f AND etc. Is that what you want? # here start problems, I suppose Yes, this is it. open (ACTUAL, - . cleaned_ones/$ARGV) || die I can't open $ARGV because $!\n; You are trying to open the file -cleaned_ones/$ARGV but the directory -cleaned_ones does not exist. print $txt; close ACTUAL; $txt = ; } } print DONE.\n; This will do what you want: #!/usr/bin/perl -w use strict; local $/; # slurp mode @ARGV = original_ones/*.txt; while ( ) { tr/\015\012/\n/s; tr/-=*^_+' //s; s/^(?:Newsgoups: it\.|(?:Subject:|Date:|Message-ID:|References:) ).+/gm; s/(\w')/$1 /g; s[(?: http:// )? \w{3,} (?:\. (?:\w-?)+ )+ \.\w{2,3} (?:/\w+ (?:\.\w{1,5})* (?:\?\w{1,32}=\w{1,32})* )* ] [ URL ]xg; s/\d+/ /g; tr/\n\r\f\t //s; if ( eof ) { close ARGV; open ACTUAL, cleaned_ones/$ARGV or die I can't open $ARGV because $!; print ACTUAL; close ACTUAL; } } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Printing epoch time
can anyone show me how I would get the screen resolution with perl in a unix environment?
Re: Iteration Question
Leon Rosenstein wrote: Hi again everyone, Hello, In a script I have a section that looks like this #Finally we have to load all extensible counters system(lodctr faxperf.ini) or die sorry couldn't do $!; system(lodctr dnsperf.ini) or die sorry couldn't do $!; system(lodctr esentperf.ini) or die sorry couldn't do $!; system(lodctr iasperf.ini) or die sorry couldn't do $! ; system(lodctr dnsperf.ini) or die sorry couldn't do $!; system(lodctr msdtcprf.ini) or die sorry couldn't do $!; system(lodctr ntdsctrs.ini) or die sorry couldn't do $!; system(lodctr ntfrsrep.ini) or die sorry couldn't do $!; system(lodctr perfci.ini) or die sorry couldn't do $!; system(lodctr perffilt.ini) or die sorry couldn't do $!; system(lodctr perfwci.ini) or die sorry couldn't do $!; system(lodctr pschdperf.ini) or die sorry couldn't do $!; system(lodctr rasctrs.ini) or die sorry couldn't do $!; system(lodctr rsvp.ini) or die sorry couldnt do $!; print all done; You are not using system() properly there. perldoc -f system [snip] The return value is the exit status of the program as returned by the `wait' call. To get the actual exit value divide by 256. See also the exec entry elsewhere in this document. [snip] @args = (command, arg1, arg2); system(@args) == 0 or die system @args failed: $? You can check all the failure possibilities by inspecting `$?' like this: $exit_value = $? 8; $signal_num = $? 127; $dumped_core = $? 128; When the arguments get executed via the system shell, results and return codes will be subject to its quirks and capabilities. See the section on `STRING` in the perlop manpage and the exec entry elsewhere in this document for details. Sometimes one of the commands fail for a reason I am not sure of (it will fail at line 29 but when I rerun the script it will fail at 35 then it will fail at 40 then it wont fail at all. I also notice that when I actually manually enter the commands through the command line it sometimes doesnt take either. Dumb question but does anyone have a clue how I could write a loop to loop through this and rerun it if it doenst complete. I was thinking of writing a loop using until. Something like until we say all done keep running the script. Since i am new to programming all together (first language and all) it is sometimes hard to get into the mentality of a programmer. Something like this should work: #Finally we have to load all extensible counters my @files = qw/faxperf.ini dnsperf.ini esentperf.ini iasperf.ini dnsperf.ini msdtcprf.ini ntdsctrs.ini ntfrsrep.ini perfci.ini perffilt.ini perfwci.ini pschdperf.ini rasctrs.ini rsvp.ini/; while ( @files ) { my $file = shift @files; if ( system 'lodctr', $file ) { warn Cannot run 'lodctr $file' $?; push @files, $file; } } print all done\n; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Printing epoch time
Subject: Re: Printing epoch time What does this have to do with Printing epoch time? [EMAIL PROTECTED] wrote: can anyone show me how I would get the screen resolution with perl in a unix environment? This works on my system (Linux). $ perl -le' ($rows, $cols) = `stty -a` =~ /rows\s+(\d+).+?columns\s+(\d+)/; print Rows: $rowsColumns: $cols ' Rows: 44Columns: 132 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: counting fork process, again
Hi Chad, I think your error lay in the place where Jenda pointed for you. Going posix way is the right way if you intend to do a lot of low level stuff your self. Mark - Original Message - From: chad kellerman [EMAIL PROTECTED] To: beginners [EMAIL PROTECTED] Sent: Monday, March 24, 2003 1:58 PM Subject: counting fork process, again Helloe everyone, I was wondering is someone can help me out with an issue with forking. I am trying to fork 8 process at a time. Here is what I have: code snippet #!/usr/bin/perl use strict; use warnings; use lib .; use BACKUP; #my own module use POSIX :sys_wait_h; my( $MAX_CHILDREN ) = 8; my( $CHILD_PIDS ) = 0; my( $maxtries ) = 7; my( $failure ) = 0; # there are actually 100 hostIds. but you should get the point.. my( @hostIds ) = 10.10.10.1, 10.10.10.2, 10.10.10.3 ,10.10.10.4; $SIG{CHLD} = \CHILD_COUNT($CHILD_PIDS); FORK: { HOSTID: foreach my $hostId ( @hostIds ) { redo HOSTID if $CHILD_PIDS = $MAX_CHILDREN; if( my $pid = fork ) { $CHILD_PIDS++; #Add the children up until we hit the max next; }elsif (defined $pid) { # In here I do some stuff with each $hostID. # To make the code easier to read, I made a module that # has a bunch of subroutines in it. #There are basically 2 subroutines that I call for each # hostID. 1 grabs the quota for each user on the hostId, #The other tars and copies the user where the script # is. I eval my connection and if some fails I # go on to the next. ex. until ( (BACKUP-QuotaIt( $hostId ) or ( $failures == $maxtries ) ) ) { $failures++; if ( $failures == $maxtries ) { my( $subject ) = Hey, WTF is up with $hosId; my( $message ) = $0 failed to connect to $hostID.; BACKUP-MailIt( $subject, $message, $daily ); #go to the next hostid next HOSTID2; } #if statememt } #until statement }elsif($! =~ /No more process/){ sleep 15; redo; #do over. }else{ # this is just a mail routine that mails be that I #can't fork my( $subject ) = Failed to fork any children; my( $message ) = $0 failed to fork anymore children. BACKUP-MailIt( $subject, $message, $daily ); die; } } # foreach loop ends } # this is the FORK sub CHILD_COUNT { my $child_pids = @_; my $child = waitpid(-1,WNOHANG); while ($child != -1 ($child_pids 0 )) { $child_pids--; $child = waitpid(-1,WNOHANG); } } end of code snippet Just typing this I realized that if I can't fork then I probably won't be able to mail myself a notification. So I gotta change that else statement with the mail notification. Anyways, the issues I am having are two fold. The first I get this warning: Not a subroutine reference at ./script.pl line 331 which is: redo HOSTID2 if $CHILD_PIDS = $MAX_CHILDREN; The second is a bigger issue. I also fork in the home made perl module for each user of the HostId I am doing. nothing crazy, just. #--# foreach $user (@users) { my( $pid ) = fork (); die Cannot fork: $! unless defined( $pid ); if ( $pid == 0 ) { #do tarring of user exit 0; } waitpid($pid,0); } #---# Here I get the error: Not a subroutine reference at BACKUP.pm line 195. which is: waitpid($pid,0); I know this is very confusing. And I might not even be posting to the right list. But I am so frustrated with trying to get this thing to work. It seems as if I have searched everywhere for examples of limiting the number of forked processes, then being able to fork with in a fork. I originally was using Parallel::ForkManager. But I found that if I set the max_processes to 8 it will start eight but will not contiue until all eight were done, then only do one at a time. That's when I decided to go the POSIX route and use fork.. But just can't get it working. I think setting the SIG{CHLD} is messing things up. BUt I am not sure. Sorry for being so drawn out. Please feel free to tear me/my code up. I am new and would really like to know how to do this. Don't worry I can take criticism pretty well... lol Thanks in advance, Chad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:
Preventing null string from matching
Dear Perl communinty, I don't exactly want to ask this now, since I just spent much of the evening trying to handle this case, but I wonder if there's an easy way to keep the following regular expression from matching if the string in the regex is null: $_ = :B000:L520:M260:M:88:8:M602:; $string_to_match=whatever; $count = () = /\b($string_to_match)\b/g; If $string_to_match is null, whatever's in $_ matches it -- and for some reason i don't understand it matches twice for every colon-delimited piece of $_, though that hardly matters. Is there an easy way to keep the null string from matching anything? It would have saved me an evening if I'd known about it. Thanks, Scott Scott E. Robinson SWAT Team UTC Onsite User Support RR-690 -- 281-654-5169 EMB-2813N -- 713-656-3629 Rob Dixon [EMAIL PROTECTED] To: [EMAIL PROTECTED] .co.uk cc: Subject: Re: Searching for the right regular expressions 03/24/03 10:08 AM Hi. Rading your post again, it looks like I kinda screwed up. Lets try again! Rob Dixon wrote: Hi Scott Scott E Robinson wrote: Dear Perl experts, I'm trying to find the right regular expressions to do some simple (?) string processing. Can anyone tell me how to do these? 1. Given a string consisting of substrings delimited by colons, such as :B520:L201:M:M260:8:G607:, my $string = ':B520:L201:M:M260:8:G607:'; how can I a. remove the single-character and all-numeric substrings (M and 8 in this example), leaving the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /[a-z]\w+/ig; print @wanted\n; output B520 L201 M260 G607 I think that's right, although it assumes that the values that aren't all-numeric start with an alpha. b. remove all but the single-character and all-numeric substrings and leave the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /\b\w\b/ig; print @wanted\n; output M 8 Right result, but fails to find '88'. Try: my @wanted = $string =~ /\b\w\d*\b/ig; c. remove all but single- or double-character substrings and all-numeric substrings and leave the rest alone? This is an array of all the wanted substrings: my @wanted = $string =~ /\b[a-z]\w?\b/ig; print @wanted\n; output M This is right, I think. (Note that this won't find '8M', but your data doesn't look like that will come up.) That's more like it! Rob -- 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: A Solution to: Using Devel::ptkdb module
It may have something to with your OS then, because under Linux (suse 8.1) using tcsh, I got it to work fine with setenv PTKDB_CODE_FONT 9x12 --- deb [EMAIL PROTECTED] wrote: I have found a solution. If I give PTKDB_CODE_FONT env variable a full font name, instead of just 9x12, it happily agrees to do my bidding. Don't know why it works this way, but it does. I'd have to dive into the code to find out, I'm sure. So, here's what I did, setenv PTKDB_CODE_FONT -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 This is not equivalent to 9x15, but that's okay, because it looks just fine. Thanks, deb I have been using the Devel::ptkdb module on SunOS, which is a really fine tool. However, the text in the code pane is extremely small. perldoc has a list of environment variables which can be used to manipulate X resources, and I tried, setenv PTKDB_CODE_FONT 9x12 And then I ran the debugger, but the font did not change in the code pane. But, if I run an xterm with xterm -fn 9x12 the xterm is displayed with the correct font size. Has anyone been able to manipulate the font size using this module? If so, what did you do to change the font size? Thanks, deb PS: I'm on the digest of this list. So, I advance my apologies if you don't hear a response from me right away. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- There are 010 types of people in the world: those who understand binary, and those who don't. ô¿ô 111,111,111 x 111,111,111 = 12,345,678,987,654,321 (decimal) ~ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Socket Problem
Hello Stefan, Ok, I replied to the previous response to my post and it apparently didn't go through, but it's irrelevant anyway. (My response to the why bother was summed up with so I can learn how it's done.) good point, although why not build the socket your self [ you can even pack raw sockets if you wish ]?? When I do the sockets this way, it waits for input on the $dccsocket without moving on to work on the information from the $socket until I send a /dcc close chat $mybotsnick... After I close the DCC CHAT connection, it reads from the $socket again without problem... I've change this recently to: in the snipet you send there is no code to handle /dcc close . The behavior you explained fallows as your code. I think the only reason you are geting past the read , is because $dccsocket points to a non valid handle. If you have warnings enabled you should get a message. With the $socket-blocking(0) and the sysread() calls, I should be able to read without problems from either one, but now it fails to even open the $dccsocket. ok before I answare that, dont mix blocking IO with NON_blocking IO[ print on socket, stdio and all high level io functions use there own buffering scheme ] atleast $|=1 on top of your script should disable stdlib buffering, I woudl avoid print and in general for NON-BLOCKING IO. print $socket PRIVMSG $channel $dcctmp\r; are you sure all data got send over this socket ?? maybe the server has closed your socket by now ?? or maybe it couldnt handle the whole message ?? If I was you I would select() to make sure socket is ready for read. check sysread if it return anything or $! might be EWOULDBLOCK. $data=PRIVMSG $channel $dcctmp\r; $status=sysread($socket,$data,$max_buff); if( defined $status){ if($status 0){print full read of $status bytes on socket if $debug); } else{ print recieved EOF on socket\n if $debug; } } elsif($! == EWOULDBLOCK){warn socket no read to be read yet\r\r;#handle how you wish } else{ warn error on socket: $!; } bypass the router and neither one works. The second may be due to the way XChat opens it's socket. If it bound it to listen on a specific IP then it may not be listening to localhost and I wouldn't be able to connect, but the only IP it should listen on if that's the case is my '192.168.x.x' IP from my router. I tried setting to that IP as well with no luck could be, if you want send me your IP and i'll give it a run. Mark - Original Message - From: Stefan Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Mark G [EMAIL PROTECTED] Sent: Monday, March 24, 2003 12:32 PM Subject: Re: Socket Problem On Sun, 23 Mar 2003 22:43:16 -0500, Mark G [EMAIL PROTECTED] wrote: Hi Stefan, If you have two different sockets open, one should not block the other no meter what kind of a socket that is. Send some of the code, might help us help you. Mark Ok, I replied to the previous response to my post and it apparently didn't go through, but it's irrelevant anyway. (My response to the why bother was summed up with so I can learn how it's done.) I added that for the benefit of the list. :) Now... the following is a snippet of the relevant code (before I changed it to use non-blocking IO.) - Cut Below -- #!/usr/bin/perl $server = 'localhost'; $port = 6667; $channel = '#mychannel'; $a = (special character for dcc, actions, etc...) $dccexists = 0; $dcctmp = ; $socket = IO::Socket::INET-new( Proto = 'tcp', PeerAddr = $server, PeerPort = $port ); unless( $socket ) { die( Could not connect to $server:$port ); } $socket-autoflush(1); while ( $tmp = $socket ) { if { $tmp ne ) { if ( $dccexists == 1 ) { $dcctmp = $dccsocket; } if ( $dcctmp ne ) { print PRIVMSG $channel $dcctmp\n; print $socket PRIVMSG $channel $dcctmp\r; $dcctmp = ; } @tmps = split( /:/, $tmp ); $command = $tmps[2]; @tmps = split( ' ', $tmp ); if ( $command =~ /DCC CHAT/i ) { $command =~ s/$a//g; $dccport = $tmps[$#tmps]; $dccip = $tmps[$#tmps-1]; $dccsocket = IO::Socket::INET-new( Proto = 'tcp', PeerAddr = $dccip, PeerPort = $dccport ); if ( $dccsocket ) { $dccexists = 1; $dccsocket-autoflush(1); print DCC CHAT\n; print $dccsocket DCC CHAT\r; print PRIVMSG $controller :Ready and waiting!\n; print $socket PRIVMSG $controller :Ready and waiting!\r; } else { print UNABLE TO ESTABLISH DCC CONNECTION TO $dccip $dccport\n; $dccexists = 0; } } } } End Cut Area When I do the sockets this way, it waits for input on the $dccsocket without moving on to work on the information from the $socket until I send a
Re: Socket Problem
On Mon, 24 Mar 2003 21:24:32 -0500, Mark G [EMAIL PROTECTED] wrote: Hello Stefan, Ok, I replied to the previous response to my post and it apparently didn't go through, but it's irrelevant anyway. (My response to the why bother was summed up with so I can learn how it's done.) good point, although why not build the socket your self [ you can even pack raw sockets if you wish ]?? Because, as I already stated :) I've already learned how to do the socket stuff with previous projects... otherwise I would :) When I do the sockets this way, it waits for input on the $dccsocket without moving on to work on the information from the $socket until I send a /dcc close chat $mybotsnick... After I close the DCC CHAT connection, it reads from the $socket again without problem... I've change this recently to: in the snipet you send there is no code to handle /dcc close. The XChat handles that. When I tell XChat /dcc close chat Botnick it closes the socket connection. behavior you explained fallows as your code. I think the only reason you are geting past the read , is because $dccsocket points to a non valid handle. No... when I have it set in blocking mode, it reads from the DCC socket just fine, so it's NOT an invalid handle... it just doesn't send to the $socket anymore until I close the $dccsocket. If you have warnings enabled you should get a message. With the $socket-blocking(0) and the sysread() calls, I should be able to read without problems from either one, but now it fails to even open the $dccsocket. ok before I answare that, dont mix blocking IO with NON_blocking IO[ print on socket, stdio and all high level io functions use there own buffering scheme ] atleast $|=1 on top of your script should disable stdlib buffering, I woudl avoid print and in general for NON-BLOCKING IO. I figured print statements were ok, since I don't care about blocking on the output to the buffers. The only reason I care whether it's blocking at all is that I thought the blocking reads might have been why the $socket wasn't being read anymore (while the $dccsocket reads worked) print $socket PRIVMSG $channel $dcctmp\r; are you sure all data got send over this socket ?? maybe the server has closed your socket by now ?? or maybe it couldnt handle the whole message ?? The server did not close the $socket because the $socket works again after closing the $dccsocket, the program just doesn't send the information down the $socket anymore while reading from $dccsocket (in blocking mode) If I was you I would select() to make sure socket is ready for read. check sysread if it return anything or $! might be EWOULDBLOCK. As I stated before, I found examples on the use of Select, but all of the examples were for a server, not a client, and the selects were designed for the accept() call... I haven't done enough work with select to figure out how to make it work the way I want it to, so basically... I don't know how to use that particular feature. If you or someone else can give a working example of IO::Select()or it's lower level counterpart, (in a client situation, NOT a server situation) I'd love to see it, so I can learn what it really does :) $data=PRIVMSG $channel $dcctmp\r; Why did we set $data equal to anything if we are reading information into it from the server? just curious :) $status=sysread($socket,$data,$max_buff); if( defined $status){ if($status 0){print full read of $status bytes on socket if $debug); } else{ print recieved EOF on socket\n if $debug; } } elsif($! == EWOULDBLOCK){warn socket no read to be read yet\r\r;#handle how you wish } else{ warn error on socket: $!; } bypass the router and neither one works. The second may be due to the way XChat opens it's socket. If it bound it to listen on a specific IP then it may not be listening to localhost and I wouldn't be able to connect, but the only IP it should listen on if that's the case is my '192.168.x.x' IP from my router. I tried setting to that IP as well with no luck could be, if you want send me your IP and i'll give it a run. I'm pretty sure it's not the router... it didn't work from work today either... and there isn't a NAT issue there. What I don't understand is WHY it's not able to create the socket with the given information. (on the nonblocking version) Thank you for taking the time to look at my code, and thank you for your suggestions. I know this is a big project to be taking on, but each time I make a mistake, I learn 2 or 3 new things and that's exactly why I started this project. I appreciate the time taken to help me with this. Respectfully, Stefan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
First program not working
I have checked my books, checked permissions, and am still having trouble. Here is my code in a file named hello.pl. I have a link to this file off my web page to test it. (Maybe this part is now right?...) - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/perl # hello.pl print Content-type: text/html\n\n; print END_OF_FILE; HTML HEAD TITLEHello/TITLE /HEAD BODY pHello, world!/p /BODY /HTML END_OF_FILE - - - - - - - - - - - - - - - - - - - - - - - - When I have this file in the CGI-BIN directory, I get an internal server error. So I put it in with my HTML files, and this is now what I get in the browser. - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/perl # hello.pl print Content-type: text/html\n\n; print Hello, world! END_OF_FILE - - - - - - - - - - - - - - - - - - - - - - - - I started with the permissions of both the CGI-Bin directory and the file at 755, then changed to 777. No luck. I have tried with both a .pl and .cgi extension. There is another .pl file in the CGI-BIN directory that works fine. It is executed on clicking a submit button. The first line of this file matches the first line of the file that works. Apache Server - Red Hat 8 __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The Loop in this script is driving me crazy.
mel awaisi wrote: Hi, The problem has been highlighted to me by a great person in this list, but i just cant solve it. I have this script that is not working as it should be. this is what it is supposed to be doing, take images from a directory (images are coming from camera) and renames them with the date and time of image. then insert some meta information into MySQL. what the script is supposed to be doing is to always keep looking and whenever it finds images to perform the change and insert. the output is as follow: it only does the process once. i would appreciate any help. cheers, Mel --- renaming /home/httpd/htdocs/image.jpg to /home/me/images/2003_03_24_18_14_12.jpg adding /home/me/images/2003_03_24_18_14_12.jpg to database [EMAIL PROTECTED] cgi-bin]# size is 196378 modified is 20030324181412 filename is 2003_03_24_18_14_12.jpg Use of uninitialized value in concatenation (.) or string at renamerr.pl line 99 . Failed to get the info $file is: at renamerr.pl line 99. In the code you sent, as copied into my editor does not show any code at the line number indicated. My tracing for the error messages indicated that this happens near the end of process(): ... print adding $new_dir/$stamp.$suffix to database\n; # This prints fine. my $single_string = $new_dir . '/' . $stamp . '.' . $suffix; infoinsert ($single_string); } It looks like you also call infoinsert after your return form process(): process($check_file) if (-r $original_dir/$check_file.$suffix); infoinsert(); This is likely to cause problems. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Iteration Question
Rosenstein, Leon wrote: Hi again everyone, Again newbie here so go easy In a script I have a section that looks like this #Finally we have to load all extensible counters system(lodctr faxperf.ini) or die sorry couldn't do $!; system(lodctr dnsperf.ini) or die sorry couldn't do $!; Hi Luke, I am wondering why you are doing this in Perl, rather than a batch file. I suspect that would would get better performace of the commands shown that way. From Perl, there is the overhead of calling the shell command interpreter with each line. Is this part of a larger program? I am also sort of curious about the command you use. I gather, from your usage, that it is intended to load the counter list for each service from its perfmon ini file. It is not documented, though, in the user interface. lodcntr /? or /help renders no output. Generally, any utility meant for direct manipulation will ahve command-line documentation available with one of these switches. When the program succeeds, do you get the results desired: is an appropriate counter added to the performance monitor? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: First program not working
Barb Konings wrote: I have checked my books, checked permissions, and am still having trouble. Here is my code in a file named hello.pl. I have a link to this file off my web page to test it. (Maybe this part is now right?...) - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/perl # hello.pl What kind of system are you working on? If you are working in Windows, one possibility is that you have FTP'd the script in binary mode, keeping the DOS carriage-returns in your newlines. Another possibility is that the server does not have a Perl installation at the locaation specified. Usually, an Internal Server Error indicateds an error has occured before the content header is printed. In your html directory, it looks like your browser or server is assuming GET as the method. This is the default for URLs typed into the address bar. It seems that your server assumes this also. If your server configuaration includes a cgi-bin directory, you should use this, and just focus on fixing errors received doing this. One thing you might try is simplifying your script header: #!perl -w If the perl executable is in your systems executable path, this should be enough. It is definitely better than giving the server an incorrect path. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: First program not working
I'm not an expert in Perl, and I matched the same kind of problems few days ago. Here you have some suggestion: 1 - Try to run it as simple perl program in the shell (# perl hello.pl) and check for errors or strange output. 2 - Go in the log directory of Apache (etc/httpd/logs) and check the error_log file 3 - I would also try with a simplest version of the program, with only one line of output (i.e. print only 'Hallo' without the HTML tags). Than, when you have a working version of your very simple program you can add the HTML tags. Good Luck and let us know! ;) Frank --- Barb Konings [EMAIL PROTECTED] wrote: I have checked my books, checked permissions, and am still having trouble. Here is my code in a file named hello.pl. I have a link to this file off my web page to test it. (Maybe this part is now right?...) - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/perl # hello.pl print Content-type: text/html\n\n; print END_OF_FILE; HTML HEAD TITLEHello/TITLE /HEAD BODY pHello, world!/p /BODY /HTML END_OF_FILE - - - - - - - - - - - - - - - - - - - - - - - - When I have this file in the CGI-BIN directory, I get an internal server error. So I put it in with my HTML files, and this is now what I get in the browser. - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/perl # hello.pl print Content-type: text/html\n\n; print Hello, world! END_OF_FILE - - - - - - - - - - - - - - - - - - - - - - - - I started with the permissions of both the CGI-Bin directory and the file at 755, then changed to 777. No luck. I have tried with both a .pl and .cgi extension. There is another .pl file in the CGI-BIN directory that works fine. It is executed on clicking a submit button. The first line of this file matches the first line of the file that works. Apache Server - Red Hat 8 __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]