Authenticating to the proxy---anyone ?
Sorry, don't mean to nag you all by asking again but thought I might be lucky to get atleast one reply this time @:) I thought this was a very typical situation most of us would have found ourselves at some point of time...proxies occur as commonly as perl itself...I reconfigured ppm and it asked my proxy details but it didn't help... -Original Message- From: Aman Thind [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 02, 2003 4:20 PM To: [EMAIL PROTECTED] Subject: Authenticating to the proxy Hullo Friends I need to authenticate to a proxy server in order to access the internet. How can I do this so that my lwp scripts may run ? I tried this but am still unable to connect to the net : use LWP::UserAgent; $ua = LWP::UserAgent-new; $ua-proxy(['http', 'ftp'] = 'http://myproxyserver:80'); $req = HTTP::Request-new(GET = 'http://www.google.com'); $req-proxy_authorization_basic(myusername, mypasswd); $res = $ua-request($req); print $res-content if $res-is_success; Also, how can I have access to the net through proxy using PPM ? I have set the user variables HTTP_proxy , HTTP_proxy_user and HTTP_proxy_pass but I still get the msg Could not locate a PPD file for... Thanks aman -- 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]
Authenticating to the proxy
Hullo Friends I need to authenticate to a proxy server in order to access the internet. How can I do this so that my lwp scripts may run ? I tried this but am still unable to connect to the net : use LWP::UserAgent; $ua = LWP::UserAgent-new; $ua-proxy(['http', 'ftp'] = 'http://myproxyserver:80'); $req = HTTP::Request-new(GET = 'http://www.google.com'); $req-proxy_authorization_basic(myusername, mypasswd); $res = $ua-request($req); print $res-content if $res-is_success; Also, how can I have access to the net through proxy using PPM ? I have set the user variables HTTP_proxy , HTTP_proxy_user and HTTP_proxy_pass but I still get the msg Could not locate a PPD file for... Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: help perl ftp
when you see the outcome of your search for Net::FTP on search.cpan.org you see something like : Net::FTP FTP Client Class perl-5.8.0 - Date - author Net::FTP FTP Client Class libnet-1.16 - Date - author DON'T click on Net::FTP, that is where you're finding the **theorotical explanation** click on perl-5.8.0 \ libnet-1.16 placed directly below it and you'll be transferred to the download page. -Original Message- From: vemulakonda uday bhaskar [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 6:05 PM To: [EMAIL PROTECTED] Subject: help perl ftp Hi AALL thoughi searched http://search.cpan.org/, i couldnot get the p[lace from where i can download NEt::FTP. I on;y got is a theorotical explanation of Net::FTP please help me in this regads with regards uday bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan Kareena Kapoor http://www.mpkdh.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: Cookies rejected
Hi Todd Thanks a lot for the pointer. WWW::Mechanize was exactly what I needed. Using it's field replacement, I could log in to the site without any problem with the cookies. However, the next web page from where I actually want to send the message contains a text box for the mobilenumber and textarea for the message. The textbox was filled with the mobile number easily using $agent-field(mobilenumber,+9198155...); Result : input TABINDEX=1 TYPE=text NAME=mobilenumber MAXLENGTH=200 SIZE=55 VALUE=+9198155... All is great till this point. The hurdle now is that I could not find any method to populate the textarea :( Here is the html line from page where I'm supposed to put the message : textarea TABINDEX=2 ID=message NAME=message COLS=45 ROWS=4 WRAP=PHYSICAL onBlur=textRemaining(); onfocus=textRemaining(); onkeydown=textRemaining(); onkeypress=textRemaining(); onkeyup=textRemaining();/textarea Could anyone please tell me how I could populate the textarea using Mechanize so that a submit() would send the msg on it's way... Thanks you so much aman -Original Message- From: Todd Wade [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 25, 2003 11:02 PM To: [EMAIL PROTECTED] Subject: Re: Cookies rejected Aman Thind [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi All On receiving no reply to my previous post, I myself struggled a bit and came up with the following code to login to the site : -- use LWP::UserAgent; use HTTP::Cookies; $ua = LWP::UserAgent-new; $ua-cookie_jar(HTTP::Cookies-new(file = lwpcookies.txt,autosave = 1)); my $req = HTTP::Request-new(POST = 'http://www.sms.ac/login.asp'); $req-content_type('application/x-www-form-urlencoded'); $req-content('loginuserid=myuseridloginpassword=mypassword'); my $res = $ua-request($req); print $res-as_string; -- However, on running this script, a web page with the following message is returned : Unable to establish login (cookies rejected). Could someone please guide me how to overcome this. You are running in to some very usual issues with http clients. Really the best we ( or at least myself ) can say is that you are not sending a properly formatted cookie. There is a module called WWW::Mechanize that helps facilitate what you are trying to do. You might want to give it a look. Todd W. -- 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]
Cookies rejected
Hi All On receiving no reply to my previous post, I myself struggled a bit and came up with the following code to login to the site : -- use LWP::UserAgent; use HTTP::Cookies; $ua = LWP::UserAgent-new; $ua-cookie_jar(HTTP::Cookies-new(file = lwpcookies.txt,autosave = 1)); my $req = HTTP::Request-new(POST = 'http://www.sms.ac/login.asp'); $req-content_type('application/x-www-form-urlencoded'); $req-content('loginuserid=myuseridloginpassword=mypassword'); my $res = $ua-request($req); print $res-as_string; -- However, on running this script, a web page with the following message is returned : Unable to establish login (cookies rejected). Could someone please guide me how to overcome this. Thanks in anticipation, aman -Original Message- From: Aman Thind [mailto:[EMAIL PROTECTED] Sent: Monday, June 23, 2003 2:05 PM To: [EMAIL PROTECTED] Subject: Log into a site and do stuff Hi I am working on a module that occasionally needs to raise alarms by sending sms to concerned ppl. For this, I would like to login to the site : www.sms.ac The login page is http://www.sms.ac/login.asp Then I have to go to the main page , fill the To: and Message: textboxes and send sms. I have no prior experience with LWP and couldn't make much use of perldoc lwpcook Could someone please tell me how I can accomplish this feat. A pointer towards a newbie resource on this perl feature or some sample code will surely help. Thanks aman -- 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]
Log into a site and do stuff
Hi I am working on a module that occasionally needs to raise alarms by sending sms to concerned ppl. For this, I would like to login to the site : www.sms.ac The login page is http://www.sms.sc/login.asp Then I have to go to the main page , fill the To: and Message: textboxes and send sms. I have no prior experience with LWP and couldn't make much use of perldoc lwpcook Could someone please tell me how I can accomplish this feat. A pointer towards a newbie resource on this perl feature or some sample code will surely help. Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ABOR message using Net::FTP
Hi My ftp script sometimes stops working after throwing an ABOR message :( I invoke the ftp as : $ftp-append(\*FH,$remotefile)||Reconnect(); But when ABOR comes, reconnect is not called. However if i take my machine out of the network while doing the ftp, it invokes Reconnect() as it should. Any remedies please... b.t.w. the msg that comes is ABOR and not ABORT incase you're thinking i'm bad at spelling... :) Thanks in advance, Aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ABOR message using Net::FTP
Hi Wiggins The appearance of ABOR is extremely random. I've successfully uploaded huge files with this script without any issues. So this is possibly being generated by the server I'm uploading my files to...but WHY ? I used the debug flag for the ftp and here's an excerpt of the output : Net::FTP=GLOB(0x1f32e14) 200 PORT command successful. Net::FTP=GLOB(0x1f32e14) APPE /Development/XPress/LatestBuild/6.0/1341/Instal ler/Mac/QuarkXPress 6.0 Installer.hqx Net::FTP=GLOB(0x1f32e14) 150 Opening BINARY mode data connection for /Develop ment/XPress/LatestBuild/6.0/1341/Installer/Mac/QuarkXPress 6.0 Installer.hqx. Net::FTP=GLOB(0x1f32e14) =ABOR Net::FTP=GLOB(0x1f32e14) 426 Connection closed; transfer aborted. Net::FTP=GLOB(0x1f32e14) 226 ABOR command successful. Net::FTP=GLOB(0x1f14100) 220 productserver Microsoft FTP Service (Version 5.0). The output stood at the 150 Opening BINARY... line till the upload was being made and then suddenly the =ABOR appeared and the transfer stopped ! How can I augment my following line of code : $ftp-append(\*FH,$remotefile)||Reconnect(); so that Reconnect is called when =ABOR springs up to make my life miserable... Thank you so much Aman -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, June 13, 2003 10:14 PM To: Aman Thind; [EMAIL PROTECTED] Subject: RE: ABOR message using Net::FTP On Fri, 13 Jun 2003 21:18:32 +0530, Aman Thind [EMAIL PROTECTED] wrote: Hi My ftp script sometimes stops working after throwing an ABOR message :( I invoke the ftp as : $ftp-append(\*FH,$remotefile)||Reconnect(); But when ABOR comes, reconnect is not called. However if i take my machine out of the network while doing the ftp, it invokes Reconnect() as it should. Any remedies please... b.t.w. the msg that comes is ABOR and not ABORT incase you're thinking i'm bad at spelling... :) From what the RFC says this is generally sent by the client to tell the server to stop doing whatever it is that it is doing, are you sure this is coming from the server side or is it being generated in your script (or Net::FTP) somehow? Presumably the ABOR is working, which is then replying with a successful message that is preventing the reconnect. You can set a Debug flag in your Net::FTP constructor that will print verbose information that may help fix the issue. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sending free SMS through perl
Hi All How can I send a free SMS through perl ? I am fighting a losing battle with WWW-SMS-0.09. I created an account on gomobile.ch but everytime i try to send an sms using gomobile as the submodule I get an error msg saying my number is not compatible with gomobile gateway...however it took the same number in it's registration form. Could anyone point me to the light please...is their a sure and simple way to achieve the same ? Thanks Aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Synchronization of FTP servers
Hi This is a typical situation in companies with development teams spread around the globe. I have FTP servers - in India , US Switzerland. Builds are being made in India and being put on the Indian server. Any tips how I could transfer the contents to the remote servers ? I've been using Net::FTP for this but sometimes I get a timeout using it and so want to move onto something more robust which could be automated as well. GNU's Wget is scriptable and downloads stuff from FTP servers...is there something like that which uploads as well ? Can I specify certain locations in a script which could initiate the uploads as soon as they find something new over there...something like Synchronize may be ? Thanks in advance... -aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Timeout at C:/Perl/lib/Net/FTP.pm line 741
Hi all , I have currently two ftp uploads being made from my machine. I am using the Net::FTP for the recursive transfer of product builds to germany. While one script is successfully transferring, the other is aborting with the following error : Timeout at C:/Perl/lib/Net/FTP.pm line 741 Both the transfer scripts are exactly the same barring the difference in source-target parameters. What does this message mean and is there any workaround ? Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Q : How to resume an ftp session + RE: Timeout at C:/Perl/lib/Net /FTP.pm line 741
As it turned out there was some problem with the file I was trying to transfer. I could not transfer it even using an ftp client. The ftp client also aborts with a time out. Another question. How can I use the *Resume* facility provided by an ftp server??? Currently on error I restart the process again. I go back to the start of the script - match the sizes of the file to upload and the one present - if different then upload - else go to next file. The incompletely transferred file is overwritten and the transfer is not resumed from where it aborted. Thanks aman -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 8:06 PM To: Aman Thind; [EMAIL PROTECTED] Subject: RE: Timeout at C:/Perl/lib/Net/FTP.pm line 741 What are the parameteres that are different and which are the same? Is then one ftp server set to timeout after xx amount of seconds? The message means ( not a dictionary definition ) basically that the server hasn't seen aby action for a specified period of time and said good bye to your script. Dan -Original Message- From: Aman Thind [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 7:39 AM To: [EMAIL PROTECTED] Subject: Timeout at C:/Perl/lib/Net/FTP.pm line 741 Hi all , I have currently two ftp uploads being made from my machine. I am using the Net::FTP for the recursive transfer of product builds to germany. While one script is successfully transferring, the other is aborting with the following error : Timeout at C:/Perl/lib/Net/FTP.pm line 741 Both the transfer scripts are exactly the same barring the difference in source-target parameters. What does this message mean and is there any workaround ? Thanks aman -- 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]
applescript power for perl on macintosh
Hi all Is there a module which would give me the power of applescripts on Mac OS 9 / 10 ? How can I invoke an application and pass it parameters like I can using applescript with methods provided in that application's dictionary ? Eg. I want to invoke Mac Metrowerks CodeWarrior, tell it the path of the project to compile and what configuration to use using perl. Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sent time in a Net::SMTP mail
Hi all, Please help me sort the following two issues : 1 ) I cannot display the Sent time in MS Outlook in a mail generated using Net::SMTP. With the code I am using , the Sent field in the Outlook pane comes blank. 2 ) I cannot reply to the mail received using this code.The email address information is lost on using names instead of email addresses in the To and Cc tabs. How can I display names and allow a reply-to-all too ? Here is the code I am using : - use Net::SMTP; $sender = '[EMAIL PROTECTED]'; $subject = Just a test...pls ignore; $body = \n html body font size= -1font color = redBIMPORTANT:/B/font This information is for internal authorized use only. /font /body /html ; my $smtp = Net::SMTP-new('my_mail_server_name');#what mailserver to use # Sender's Address $smtp-mail('[EMAIL PROTECTED]'); # Who will receive the notification mail? $smtp-to('[EMAIL PROTECTED]','[EMAIL PROTECTED]','[EMAIL PROTECTED]' ); #place the actual data within the email $smtp-data(); $smtp-datasend(Content-type: text/html\n); $smtp-datasend(From: Aman Thind\n); $smtp-datasend(To : Aman Thind\n); $smtp-datasend(Cc : Shishir Saxena; Manish Kashyap\n); $smtp-datasend(Subject : .$subject.\n); #Here is the body $smtp-datasend(\n); $smtp-datasend($body); $smtp-dataend(); $smtp-quit; - Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sent time in a Net::SMTP mail
Thanks a lot Jenda...u're a real wizard :) There are still just two minor issues which I thought I should bring to your notice... The time displayed is 30 mins more than the actual time here. The To \ From tab now reads : Aman Thind [[EMAIL PROTECTED]]. Can't I just do away with the email address ? Thanks again aman -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 7:38 PM To: [EMAIL PROTECTED] Subject: Re: Sent time in a Net::SMTP mail From: Aman Thind [EMAIL PROTECTED] Please help me sort the following two issues : See below. 1 ) I cannot display the Sent time in MS Outlook in a mail generated using Net::SMTP. With the code I am using , the Sent field in the Outlook pane comes blank. 2 ) I cannot reply to the mail received using this code.The email address information is lost on using names instead of email addresses in the To and Cc tabs. How can I display names and allow a reply-to-all too ? Here is the code I am using : -- -- - use Net::SMTP; $sender = '[EMAIL PROTECTED]'; $subject = Just a test...pls ignore; $body = \n html body font size= -1font color = redBIMPORTANT:/B/font This information is for internal authorized use only. /font /body /html ; my $smtp = Net::SMTP-new('my_mail_server_name'); #what mailserver to use # Sender's Address $smtp-mail('[EMAIL PROTECTED]'); # Who will receive the notification mail? $smtp-to('[EMAIL PROTECTED]','[EMAIL PROTECTED]','mkashyap@quark. co.in' ); #place the actual data within the email $smtp-data(); $smtp-datasend(Content-type: text/html\n); #time diference to GMT - Windows will not set $ENV{'TZ'}, if you know a better way ... my $GMTdiff; { my $time = time(); my @local = (localtime($time))[2,1,3,4,5]; # hour, minute, mday, month, year; I don't mind year is 1900 based and month 0-11 my @gm = (gmtime($time))[2,1,3,4,5]; my $diffdate = ($gm[4]*512*32 + $gm[3]*32 + $gm[2]) = ($local[4]*512*32 + $local[3]*32 + $local[2]); # I know there are 12 months and 365-366 days. Any bigger numbers work fine as well ;-) if ($diffdate 0) {$gm[0]+=24} elsif ($diffdate 0) {$local[0]+=24} my $hourdiff = $gm[0]-$local[0]; my $mindiff; if (abs($gm[1]-$local[1])5) { $mindiff = 0 } elsif (abs($gm[1]-$local[1]-30) 5) { $mindiff = 30 } elsif (abs($gm[1]-$local[1]-60) 5) { $mindiff = 0; $hourdiff ++; } $GMTdiff = ($hourdiff 0 ? '+' : '-') . sprintf %02d%02d, abs($hourdiff), $mindiff; } my $date = localtime(); $date =~ s/^(\w+)\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)$/$1, $3 $2 $5 $4/; $smtp-datasend(Date: $date $GMTdiff\n; $smtp-datasend(From: Aman Thind\n); $smtp-datasend(From: \Aman Thind\ [EMAIL PROTECTED]\n); Same for the other addresses. $smtp-datasend(To : Aman Thind\n); $smtp-datasend(Cc : Shishir Saxena; Manish Kashyap\n); $smtp-datasend(Subject : .$subject.\n); #Here is the body $smtp-datasend(\n); $smtp-datasend($body); $smtp-dataend(); $smtp-quit; 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sent time in a Net::SMTP mail
Hi Jenda Apparently the time zones are correct on my machine. Statements : print scalar(localtime).\n; print scalar(gmtime).\n; Output : Fri Jan 3 20:35:34 2003 Fri Jan 3 15:05:34 2003 India is +5:30. However I think i caught the bug... The statement : elsif (abs($gm[1]-$local[1]-30) 5) should be replaced by : elsif (abs(abs($gm[1]-$local[1])-30) 5) and similarly for the next elsif. The script runs like a spell thereafter :) Thank you so much Keep crooning... :-) aman -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 8:37 PM To: [EMAIL PROTECTED] Subject: RE: Sent time in a Net::SMTP mail From: Aman Thind [EMAIL PROTECTED] Thanks a lot Jenda...u're a real wizard :) Shame I can't even get drunk :-} There are still just two minor issues which I thought I should bring to your notice... The time displayed is 30 mins more than the actual time here. Are you sure the timezone is set correctly on your computer? Could you see what do these two print? print scalar(localtime).\n; print scalar(gmtime).\n; Do the times look correct? The To \ From tab now reads : Aman Thind [[EMAIL PROTECTED]]. Can't I just do away with the email address ? I don't think so. 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Error msg executing Berkeley DB
Hi I am trying to configure the mozilla tinderbox on a unix machine. In order to execute a query , I am using the Berkeley DB and DB_File modules. I am getting the following error message : cvstest:/usr/local/lxr # perl search DB_File object version 1.806 does not match bootstrap parameter 1.804 at /usr/local/lib/perl5/5.8.0/i686-linux/DynaLoader.pm line 249. Compilation failed in require at lib//LXR/Common.pm line 5. BEGIN failed--compilation aborted at lib//LXR/Common.pm line 5. Compilation failed in require at search line 27. BEGIN failed--compilation aborted at search line 27. any suggestions... Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: picking numbers out of a file and operating on them
Hi, # == # # Perl Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM) # # NAME: Nandita.pl # # AUTHOR: Aman Thind , Quark Inc # DATE : 12/16/2002 # # PURPOSE: comment # # == $file = 'C:\Documents and Settings\athind\Desktop\nandita.txt'; open FILE , $file; while(FILE) { if(/Length *= *([0-9]*)/) { push @Ln , $1; } if(/Identities.*\/ *([0-9]*)/) { push @Dn , $1; } } for($i=0 ; $i scalar(@Ln) ; $i++) { if(@Ln[$i]!= 0) { $percentage = @Dn[$i]*100/@Ln[$i]; } else { print Length = 0 in Blah; print $i+1; print !\n; die; } push @Blah,$percentage; if(@Blah[$i] 50) { print BLAH; print $i+1; print \n } } # This should do the job. Please adapt it to your liking. -aman. -Original Message- From: Nandita Mullapudi [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 14, 2002 3:31 AM To: [EMAIL PROTECTED] Subject: picking numbers out of a file and operating on them How does one tell perl to perform mathematical operations? I have a file with a series of items like this: BLAH1 Length = 500 Identities = 20/100. BLAH2 Length = 400 Identities = 30/70 For each item called BLAH, I want to pick the denominator in Identites and divide by Length and calculate percentage. Eg. for BLAH1: 100/500 * 100 = 20% and later , print all BLAHs for which the value is 50%. I csn write reg exps to find the numbers i am interested in, but am not sure how to go further.. thanks, -nandita -- 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: again a regex help needed
Hi $file1='doctobepublish.new.pdf'; if ($file1 =~ /\.[^\.]*\./) { print Multiple Dots!; } else { print Single Dot!; } -aman. -Original Message- From: Marco Centemeri [mailto:[EMAIL PROTECTED]] Sent: Monday, December 16, 2002 12:41 PM To: Perl Beginners Mailing List Subject: again a regex help needed Hello All, I'd like to know if a file name is like namefile.ext (only one dot in the name) or namefile.xxx.z.ext (more than one dot in the name). I tried with regex: $file1='doctobepublish.new.pdf'; if ( $file1 =~ /\.{2,}/ ) { print KO filename not properly formatted; } else { print OK filename is good; } This doesn't work and the match is true only if the two dots are consecutive. doctobepublish.new.pdf =~ /\.{2,}/ doesn't match doctobepublish..new.pdf =~ /\.{2,}/ match My idea, probably wrong, is that regex process scan all the string and try to match all the possible so doctobepublish.new.pdf =~ /\.{2,}/should match anotherdoctobepublish.pdf =~ /\.{2,}/ should not match May anybody help me to solve the problem and to understand better how regex works? I've already read perlquik and perlre but some points are still foggy! Thanks a lot Marco Centemeri -- Eng. MARCO CENTEMERI Telecommunication and Peripherals/Automotive Groups Audio Automotive Division Automotive Business Unit Bosch Product Engineer STMicroelectronics Srl Tel: +39.039.603.5784 20041 Agrate Brianza - Italy Fax: +39.039.603.6343 Via C. Olivetti, 2 Mobile: +39.0348.8861577 Building F11 [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]
Extracting plain text from MS Word Document
Hi I need to extract the text from a word document. I know how to : Print a word document using the default printer : - use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $Word = Win32::OLE-new('Word.Application', 'Quit'); # $Word-{'Visible'} = 1; # if you want to see what's going on $Word-Documents-Open(C:\\DOCUMENTS\\test.doc) || die(Unable to open document , Win32::OLE-LastError()); $Word-ActiveDocument-PrintOut({ Background = 0, Append = 0, Range = wdPrintAllDocument, Item = wdPrintDocumentContent, Copies = 1, PageType = wdPrintAllPages, }); - Create a new word document : - use Win32::OLE; # check if Word exists my $x = Win32::OLE-GetActiveObject('Word.Application'); die Word not Installed if $@; # start Word program die if unable to unless (defined $x) { $x = Win32::OLE-new('Word.Application', sub { $_[0]-Quit; } ) or die 'Cannot start Word'; } # Create new document my $d = $x-Documents-Add; # define selection my $s = $x-Selection; #set lines to be written to document @line = ('This is a test line', 'This is second test Line', 'This is the third line', ); # $c is the color # $start is the start of Range # $end is the end of Range # $r is the Range object my ($c, $start, $end, $r) = (2, 0, 0, ); foreach (@line) { $end += length($_) + 1; # put the text $s-TypeText($_); # define the Range $r = $d-Range($start, $end); # Set font to 12 and color $r-Font-{Size} = 12; $r-Font-{ColorIndex} = $c++; $s-TypeText(\n); $start = $end; } # List Range Objects ListObj($r); #List Document Objects ListObj($d); sub ListObj { foreach (sort keys %$r) { print Keys: $_ - $r-{$_}\n; } } undef $x; - Now I want to extract the text from the word document and store it in a string for manipulation. I've been hacking at it for two days now but success remains illusive :( I would also like to use this as an MS Word to Plain Text conversion utility. Any help would be greatly appreciated. -aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: random string
Miss P Some people say that I have to pay for writing the script. Me ???what are such ppl doing here anyway??? we're all here to help each other out aren't we ? these ppl are requested to put their hoardings elsewhere... pay and that too for a beginner exercise...hilarious :D Miss P I couldn't make heads and tails out of this. If you had given only John's solution and a mail in Hebrew, I would have not able to make out the difference ;-) Me hmmm. I personally believe John's solution was as elegant as they come. Probably your predicament is you don't know how to use it. Just copy-paste the following in a file and save it with the extension .pl #--- open PASWDFILE , pswdfile # you may want to replace what's in the quotes #with the exact path of the pswd file you want to generate # character set to choose from as per your example my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 ); # pick eight random characters from the array my $string = join '', map $chars[ rand @chars ], 1 .. 8;#don't bother with the howz and whyz of this line...just use it ;) print $string; #just so that you know what is being written into the file...comment it out later. print PASWDFILE , $string; #write the random string of length 8 in the file #--- Your application could then read this generated file and use the randomstring as you desire. Once it's contents have been read , do unlink(delete) this file using your bash program. Miss P and when I didn't receive any concrete answers I was led to believe that it cannot be accomplished in perl easily even by advanced users. Me hope your belief has been belied :) Miss P I wish I can write col perl programs. I will be instant hit here, especially with guys ;-) Me ... only if you write real *beautiful* code and have read the perl *Cook*book :D -aman --- Nishkaam Sevabhaav --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: reg ex question
Hi Melanie If it's regex you wanna use, here it is : $fullpath = '/usr/local/home/mel/file.txt'; $fullpath =~ /(.*)\/(.*)\.(.*)/; $path = $1; $file = $2; $ext = $3; -aman. -Original Message- From: Melanie Rouette [mailto:mrouette;omnisig.com] Sent: Friday, November 15, 2002 8:49 PM To: beginners Subject: reg ex question Hi, I have something like: /usr/local/home/mel/file.txt and I'd like to strip it so that I can put the path in a variable, the file name in another one and the extention in a another one as well. How do I do that, can I do it all in a same expression. Something like, $path = /usr/local/home/mel, $filename = file and finally $ext = txt. Thanks in advance. Melanie -- 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: Sending mail under Windows 95/2000
Hi Just use shaw instead of shaw.ca as in : $smtp = Net::SMTP-new('shaw')||die(my woes are never ending :(); You are supposed to use only the name of the mail server. shaw.ca is an invalid argument to Net::SMTP as you will find if you use : print $!; after trying to connect to the server as you do. Bon Mailing :) -aman. -Original Message- From: Tin-Shan Chau [mailto:tchau;shaw.ca] Sent: Wednesday, November 13, 2002 7:37 AM To: Timothy Johnson; 'Kipp, James'; 'Help on PERL' Subject: Re: Sending mail under Windows 95/2000 I did find out that the problem is with: $smtp = Net::SMTP-new('shaw.ca'); by adding or die However, I am able to send e-mail to myself using MS Access. Any other idea what my problem might be? Thanks. - Original Message - From: Timothy Johnson [EMAIL PROTECTED] To: 'Kipp, James' [EMAIL PROTECTED]; 'Tin-Shan Chau' [EMAIL PROTECTED]; 'Help on PERL' [EMAIL PROTECTED] Sent: Monday, November 11, 2002 12:26 PM Subject: RE: Sending mail under Windows 95/2000 Make sure that your sysadmin is allowing internal clients to connect to the mail server via SMTP. You might be set up on Exchange, in which case you might not be using SMTP to connect. -Original Message- From: Kipp, James [mailto:James.Kipp;mbna.com] Sent: Monday, November 11, 2002 12:16 PM To: 'Tin-Shan Chau'; 'Help on PERL' Subject: RE: Sending mail under Windows 95/2000 $smtp = Net::SMTP-new('shaw.ca'); # connect to an SMTP server $smtp-mail( '[EMAIL PROTECTED]' );# use the sender's address here $smtp-to('[EMAIL PROTECTED]');# recipient's address $smtp-data(); # Start the mail connection It kept giving me Can't call method 'mail' on an undefined value at test1.pl line 4 Does anyone have any idea how to fix this? Or has anyone had a successful experience doing what I am trying to do? Thanks. try using $smtp-recipient instead of mail() woops, scratch that. i misread something. try a die statement when you intialize the ojbect $smtp = Net::SMTP-new('shaw.ca') or die blah, blah; # connect # looks like you may not be connecting -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: file editting
Hi Thomas File editing is particularly easy in perl. Herez some sample code to get you started : -- @ARGV='C:\Documents and Settings\athind\Desktop\test\File2Edit.txt'; # path to the file you want to edit $^I=.bak; # this will be appended to the original filename and will act as BackUp. while () { s/!//; # will replace ! with nothing i.e. all instances of ! will be removed. s/SUB-TOTAL://; # same as above for SUB-TOTAL: print; # writes the new file line by line } Try this on the file you want to edit. Anything else you want to edit\replace can be done by the s/what2replace/bywhat2replace/; -aman -Original Message- From: Thomas Browner [mailto:thomas.browner;digidyne.com] Sent: Wednesday, November 13, 2002 7:33 PM To: [EMAIL PROTECTED] Subject: file editting I there away to edit a file in perl? This is what is I am trying to do. I have a file that I want to remove some content. This is an example of a line: ! 6134.21 3200 SUB-TOTAL: M:\alvin I want to remove the ! and SUB-TOTAL. I hope some one can tell me an simple way of doing this sine I am a new to perl. Thank you, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: win32::File
Hi Mark , All I have written plenty of scripts involving directory traversals and -d \ -f have never let me down. One of my scripts runs daily on an NT machine. The line I use for distinguishing between files and directories is : $type = f unless ((-d $lclpath\\$name)($type=d)); The $lclpath is the current directory I have opened using opendir and $name is the current directory entry I get using readdir(). Then we may continue as ... if ($type eq f) { } else { . } Check again and see if this helps... -aman -Original Message- From: Mark Goland [mailto:mgoland;optonline.net] Sent: Friday, November 08, 2002 12:45 PM To: perl Subject: win32::File Hi all, I am trying to do directory traversal on NTFS. When I test fileif its a directory or a regular file. It does not seem to work. -d anf -f test's dont seem to work as well. Can someone please look over my error. Thankx in advance, Mark #!c:\perl\bin\perl -w use Win32::File ; my_trav('.'); sub my_trav(){ $DIRNAME.=$_[0]; print in dir $DIRNAME\n; opendir DIR,$DIRNAME; @dir=readdir DIR; foreach $Val(@dir){ Win32::File::GetAttributes($Val, $attr); print Direcotry:\t$Val\tattrib=$attr\n if ( $attr DIRECTORY); print File:\t$Val\tattrib=$attr\n if ( $attr NORMAL); } -- 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: sort two patterns, control structure help needed
Hi Alan , All Just in case the data structures and the sort routines intimidate you , the following hack works too : #usage : [perl.exe \ perl] reorder.pl infilepath reorderedOutFilePath open INFILE, @ARGV[0] or print can't open INFILE! ; open OUTFILE, @ARGV[1] or print can't create OUTFILE! ; while(INFILE) { if(/^[0-9]{2}:/) { print OUTFILE $_; } else { push @temp , $_ ; } } close INFILE; foreach $element(@temp) { print OUTFILE $element; } close OUTFILE; Just copy paste the above program and it'll do the trick :) -aman. -Original Message- From: Alan C. [mailto:acummingAT;cwnetDOT.com] Sent: Friday, November 08, 2002 2:53 PM To: [EMAIL PROTECTED] Subject: sort two patterns, control structure help needed Hello, This must be easy. But I've not yet enough experience with Perl's control structures. perl mysort.pl infile.txt outfile.txt The stack of numbers with colons below reside within infile.txt 120:2 126:2 13:15 140:3 14:3 141:3 14:3 15:11 My task or goal is to get each of them lines over into outfile.txt (as re ordered lines) with all of the \d\d: (2 digits then colon) up at top of file then with the 3 digits colon underneath How to set up a twice through instead of only 1 pass through of the infile.txt? (and get all of the 2digits on 1st pass, then get all of the 3 digits on second pass)? Or, same task/goal done even yet a different way is ok too. #!/perl/bin/perl -w # mysort.pl while ($line = ) { if ($line =~ m/\b\d\d(?=:)/) { print $line; if ($line =~ m/\b\d\d\d(?=:)/) { print $line; } } } That above gets/snags all the 2 digits only. There's no 3 digits to outfile.txt -- Thanks. Alan. -- 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: Julian Date
Hi Steve, All Herez how you do it : $sec = (localtime())[0]; $min = (localtime())[1]; $hour = (localtime())[2]; print Time = $hour : $min : $sec\n; $day = (localtime())[3]; $month = (localtime())[4] + 1; $year = (localtime())[5]; $year = $year + 1900; print Date = $month \\ $day \\ $year; -aman. -Original Message- From: Steve [mailto:fouttyw;hawaii.rr.com] Sent: Friday, November 08, 2002 7:26 PM To: [EMAIL PROTECTED] Subject: Julian Date Can anyone tell me how to get the Julie Date via perl. I have an application that the user wants to have the julian date as part of a tracking number.. Thanks, Steve -- 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: pattern
Hi Javed Try the following regex : @testList = (SDK_0.9.4.5_20020711_IR_DEV,SDK_0.9.4.5_20020711_IR,SDK0.9.4.5_2002071 1_IR_DEV) ; foreach $testName(@testList) { if($testName =~ /^SDK[_0-9.]*_IR(_DEV){0,1}$/) { print match successful for $testName ! :)\n; } else { print match failed for $testName ! :(\n; } } It's much more elegant and flexible :) and i've tried to catch all the exceptions that may occur in the matching. Any suggestions \ queries...please let me know. -aman. -Original Message- From: Javeed SAR [mailto:SAR.Javeed;sisl.co.in] Sent: Thursday, November 07, 2002 12:20 PM To: [EMAIL PROTECTED] Subject: pattern Hi all, I want to input a string which is used to create file name, and I want to allow input string to consist of letters(SDK) at the start and only IR and DEV inbetween, and numbers(0-9) and underscore( _ ) within file name. Is the pattern right. m/^SDK[0-9]|^SDK_[0-9]|^SDK_[0-9]_IR|^SDK_[0-9]_IR_DEV$/ if ($input =~ /what pattern /){ create file } else { exit 0; } Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: pattern
Could you give some examples of legitimate filenames of all varieties you want ? that would help me \ us to make unambiguous test cases to ascertain your regex and suggest improvements... -aman. -Original Message- From: Javeed SAR [mailto:SAR.Javeed;sisl.co.in] Sent: Thursday, November 07, 2002 12:00 PM To: [EMAIL PROTECTED] Subject: pattern Hi all, I want to input a string which is used to create file name, and I want to allow input string to consist of letters(SDK) at the start and only IR and DEV inbetween, and numbers(0-9) and underscore( _ ) within file name. Is the pattern right. m/^SDK[0-9]|^SDK_[0-9]|^SDK_[0-9]_IR|^SDK_[0-9]_IR_DEV$/ if ($input =~ /what pattern /){ create file } else { exit 0; } Regards j@veed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: depot?
Hi Yeah sure. You could look it up in : ftp://theoryx5.uwinnipeg.ca/pub/other I found my win32 tar there. Thanks Aman -Original Message- From: PRADEEP GOEL [mailto:pradeepg;india.hp.com] Sent: Wednesday, November 06, 2002 12:33 PM To: Aman Thind; [EMAIL PROTECTED] Subject: depot? Thanks Aman can u also tell me some site to download perl 5.8 gz or tar.gz for hp ux 11.00 i downloaded some , but they r depot.gz - i don't know about depot- or how to use them Regards Pradeep - Original Message - From: Aman Thind [EMAIL PROTECTED] To: PRADEEP GOEL [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:20 PM Subject: RE: could 5.8 make a difference in place of 5.6 ? 5.8 is perfectly backward compatible and no exception has been thrown in my period of it's usage. I have recently upgraded from 5.6.1 to 5.8 and my old scripts run perfecly fine. So any script that is good enuff for 5.6 is good enuff for 5.8 Thanks Aman -Original Message- From: PRADEEP GOEL [mailto:pradeepg;india.hp.com] Sent: Wednesday, November 06, 2002 12:13 PM To: [EMAIL PROTECTED] Subject: could 5.8 make a difference in place of 5.6 ? I am writing and/or modifying some perl scripts - they have they r for test automation for installation of some product and/or its patches , scripts have basic requoirement as perl 5.6.1 must be installed on the machine wherever r scripts gona fired , now my question could it make a difference(such as script may not run) if it s an upgraded 5.8 version instead of 5.6 ? Regards Pradeep -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Include files in PERL
Yeah this will sure do the trick but just in case you need another option to do the same , require is also there to the rescue. Just put all the functions you require in a separate .pl file. The following solution can also be implemented as : # # Sample.pl sub InsertSpaces{ my @text = split //,$_[0]; #get characters of function parameter return join(' ',@text);#return string made of chars w/spaces between } 1; # required so that file can be correctly included in another script #- gives a 'true' response when loaded # # # RequireSample.pl use strict; use warnings; require 'C:\WINNT\Profiles\athind\Desktop\Sample.pl'; #location of the perl file acting as a repository of all the functions my $text = InsertSpaces(Hello World!); print $text; # This prints H e l l o W o r l d ! too. Take your pick :) Thanks Aman -Original Message- From: Timothy Johnson [mailto:tjohnson;sandisk.com] Sent: Wednesday, November 06, 2002 9:17 AM To: 'Johnstone, Colin'; '[EMAIL PROTECTED]' Subject: RE: Include files in PERL I think 'use' is what you're looking for. But just in case, perldoc -f require perldoc -f use perldoc perlmod On the last one, I would recommend reading the first section and then skipping down to the Perl Modules section. Then you can go back over the whole thing. Just to give you a taste of how modules work, here's a sample ...pm file. Don't forget the 1 at the end. # # Sample.pm package Tim::Sample; #assumes the file is at .../site/lib/Tim/ sub InsertSpaces{ my @text = split //,$_[0]; #get characters of function parameter return join(' ',@text);#return string made of chars w/spaces between } 1 # # # Sample.pl use strict; use warnings; use Tim::Sample; my $text = Tim::Sample::InsertSpaces(Hello World!); print $text; # This prints H e l l o W o r l d !. -Original Message- From: Johnstone, Colin [mailto:Colin.Johnstone;det.nsw.edu.au] Sent: Tuesday, November 05, 2002 7:17 PM To: '[EMAIL PROTECTED]' Subject: Include files in PERL Gidday from downunder, When writing PHP if I want to an include I type include(filename.php); Is there a similar command in PERL, does require do the job? In my mailing list application I re-use numerous functions and would like to pop these in a function library and include them on every page. Colin Johnstone Website Project Officer NSW Department of Education and Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]