From sas1 at ananzi.co.za Mon Aug 4 04:21:16 2003 From: sas1 at ananzi.co.za (Stanton Scott) Date: Mon Aug 2 21:40:00 2004 Subject: [Za-pm] Expect module Message-ID: Hi, Im fairly new to perl. Ive been messing around with the expect module trying to get it to work with the UNIX passwd function. I have unforntunately hit a problem. It seems when I try to use the expect function with passwd it matches the first password entry request and sends the correct response to the passwd application. Unfortunately on password confirmation it is not always able to match the request for password confirmation, thus timeing out. I have tested this routine using the same user and password for about 5-10 attempts, each time the percentage of requested passed and failed varies. Sometimes the requests passed out number the request failed and sometimes it is the other way around. Here is the part of the routine where the expect function is used: ##set the users unix password sub set_user_unix_password { my $passwd_exp=Expect->spawn("passwd", $new_user) or die "error: could not spawn password process\n"; $passwd_exp->log_stdout(0); $passwd_exp->debug(0); #user password @passwd_return=$passwd_exp->expect(10, "New password:"); $passwd_exp->send("$user_password\r\n"); # check password printf "*** password section ****\n"; printf "match : $passwd_return[0]\n"; printf "why returned : $passwd_return[1]\n"; printf "string matched: $passwd_return[2]\n"; printf "before matched: $passwd_return[3]\n"; printf "after matched : $passwd_return[4]\n"; #confirm password @passwd_return=$passwd_exp->expect(10, "Retype new password:"); $passwd_exp->send("$user_password\r\n"); # check confirmed password printf "*** password confirm section ****\n"; printf "match : $passwd_return[0]\n"; printf "why returned : $passwd_return[1]\n"; printf "string matched: $passwd_return[2]\n"; printf "before matched: $passwd_return[3]\n"; printf "after matched : $passwd_return[4]\n"; $passwd_exp->soft_close(); } If anybody could help with this it would be much appreciated. Thanks, Stanton. == Download ringtones, logos and picture messages at Ananzi Mobile Fun. http://www.ananzi.co.za/cgi-bin/goto.pl?mobile From sas1 at ananzi.co.za Mon Aug 4 07:52:56 2003 From: sas1 at ananzi.co.za (Stanton Scott) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] Expect module In-Reply-To: Message-ID: Hi All, Thanks got it working. On Mon, 04 Aug 2003 11:21:16 +0200 "Stanton Scott" wrote: > Hi, > > Im fairly new to perl. Ive been messing around with the > expect module trying to get it to work with the UNIX > passwd > function. I have unforntunately hit a problem. > > It seems when I try to use the expect function with > passwd > it matches the first password entry request and sends the > correct response to the passwd application. Unfortunately > on password confirmation it is not always able to match > the > request for password confirmation, thus timeing out. > > I have tested this routine using the same user and > password > for about 5-10 attempts, each time the percentage of > requested passed and failed varies. Sometimes the > requests > passed out number the request failed and sometimes it is > the other way around. > > Here is the part of the routine where the expect function > is used: > > > ##set the users unix password > sub set_user_unix_password { > my $passwd_exp=Expect->spawn("passwd", $new_user) or > die "error: could not spawn password process\n"; > $passwd_exp->log_stdout(0); > $passwd_exp->debug(0); > > #user password > @passwd_return=$passwd_exp->expect(10, "New > password:"); > $passwd_exp->send("$user_password\r\n"); > # check password > printf "*** password section ****\n"; > printf "match : $passwd_return[0]\n"; > printf "why returned : $passwd_return[1]\n"; > printf "string matched: $passwd_return[2]\n"; > printf "before matched: $passwd_return[3]\n"; > printf "after matched : $passwd_return[4]\n"; > > > #confirm password > @passwd_return=$passwd_exp->expect(10, "Retype new > password:"); > $passwd_exp->send("$user_password\r\n"); > # check confirmed password > printf "*** password confirm section ****\n"; > printf "match : $passwd_return[0]\n"; > printf "why returned : $passwd_return[1]\n"; > printf "string matched: $passwd_return[2]\n"; > printf "before matched: $passwd_return[3]\n"; > printf "after matched : $passwd_return[4]\n"; > > $passwd_exp->soft_close(); > } > > > If anybody could help with this it would be much > appreciated. > > > Thanks, > Stanton. > > == > Download ringtones, logos and picture messages at Ananzi > Mobile Fun. > http://www.ananzi.co.za/cgi-bin/goto.pl?mobile > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm == Download ringtones, logos and picture messages at Ananzi Mobile Fun. http://www.ananzi.co.za/cgi-bin/goto.pl?mobile From nico at itfirms.co.za Mon Aug 4 12:39:19 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] Get Together Message-ID: <200308041939.19982.nico@itfirms.co.za> Hi I wondered if any of you know about the planned "Opensource Expo". I was wondering if this could be an oppertunity for a get together. Let me know what you thinks :) PS: I am trying to confirm the event, URL, dates etc... Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From contrafa at biology.und.ac.za Tue Aug 5 03:03:48 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] behaviour of opendir Message-ID: <1060070504.6792.31.camel@contra> Hi folks; I have come across a weird behaviour on the part of "opendir" and "readdir", which I can't understand. Maybe the experienced "gurus" have figured out what is going on and may be able to clarify the issue. Take the following code, which produces a hyperlinked list of directories: #!/usr/bin/perl print "usual headers"; $input = shift; $path = "some directory"; # or a value passed from something else opendir(DIR, $path) || die(); @folder=readdir(DIR); foreach $entry (@folder) { print "$entry
"; } So far as I can see, there's nothing wrong with it and it usually works fine. Now, I've added a couple new directories to the $path folder and opendir (or, maybe, readdir) fails to see them and insists in printing the older list of folders in $path. Ownerships and privileges are fine and the new directories are seen from the shell and the desktop file manager. This happens under a browser environment as well as while testing from the shell. Using a different function (open pipe) works fine so that the following snippet prints all the directories (including the new ones): open(DIR, "ls $path |") || die(); @folder=; # or while loop foreach $entry (@folder) { .......... Am I being daft, or is there a sensible reason as to why this should be happening? ciao --- The surest way to success is sincerity. Once you can fake that, you've got it made! A. Bloch #################################################################### Dr. Giancarlo Contrafatto School of Life and environmental Sciences University of Natal, 4041, Durban, RSA Tel: +27 031 2603336 contrafa@biology.und.ac.za #################################################################### visit Darwin at http://contra.biology.und.ac.za/ From oskar at qualica.com Wed Aug 6 07:25:16 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] behaviour of opendir In-Reply-To: <1060070504.6792.31.camel@contra> References: <1060070504.6792.31.camel@contra> Message-ID: <20030806122516.GQ22259@qualica.com> Hi there > #!/usr/bin/perl > > print "usual headers"; > > $input = shift; > $path = "some directory"; # or a value passed from something else > > opendir(DIR, $path) || die(); > @folder=readdir(DIR); > foreach $entry (@folder) { > print "$entry
"; > } > > So far as I can see, there's nothing wrong with it and it usually works > fine. Now, I've added a couple new directories to the $path folder and > opendir (or, maybe, readdir) fails to see them and insists in printing > the older list of folders in $path. > Ownerships and privileges are fine > and the new directories are seen from the shell and the desktop file > manager. This happens under a browser environment as well as while > testing from the shell. Using a different function (open pipe) works > fine so that the following snippet prints all the directories (including > the new ones): A couple of thoughts here. First off, the code looks fine - it shouldn't be doing strange things like this. Normally I do something like this: #!/usr/bin/perl -w use strict; my $path = "/tmp"; opendir(DIR, $path) || die("Cannot opendir: $!"); foreach my $entry (readdir(DIR)) { print "$entry\n"; } So, I think the reason you've not got any answers (at least on the list) is that something is very strange :) Here are some possibilities: 1) are you doing this in an nfs mounted directory? I've seen caching that sometimes returns old results in NFS. This would explain why you get it in all cases (not just from a web page). 2) Are you doing this in mod-perl? If so, it's perhaps possible that one or more variables isn't being cleared out when you hit the page the second time. In the simple example above this is less likely, but if it's just a "for example case" then perhaps this is the problem. You might want to try giving everything a defined scope, and using variables to hold the directory name: #!/usr/bin/perl -w use strict; my $path = "/tmp"; { # scoped to ensure limited lifetime my $dir; opendir($dir, $path) || die("Cannot opendir: $!"); foreach my $entry (readdir($dir)) { print "$entry\n"; } } Please let us know the results! Oskar From contrafa at biology.und.ac.za Wed Aug 6 07:46:56 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] behaviour of opendir: reply to Oskar's reply In-Reply-To: <20030806122516.GQ22259@qualica.com> References: <1060070504.6792.31.camel@contra> <20030806122516.GQ22259@qualica.com> Message-ID: <1060173832.8131.16.camel@contra> On Wed, 2003-08-06 at 14:25, Oskar Pearson wrote: > > A couple of thoughts here. First off, the code looks fine - it shouldn't > be doing strange things like this. > > Normally I do something like this: > #!/usr/bin/perl -w > use strict; > my $path = "/tmp"; > opendir(DIR, $path) || die("Cannot opendir: $!"); > foreach my $entry (readdir(DIR)) { > print "$entry\n"; > } > > > So, I think the reason you've not got any answers (at least on the list) > is that something is very strange :) Hehehe! Yes, that's why I thought it'd be worth bring it up. > > Here are some possibilities: > > 1) are you doing this in an nfs mounted directory? I've seen caching > that sometimes returns old results in NFS. This would explain why you > get it in all cases (not just from a web page). Yep, somewhat. This came out of an exchange I've had with Spike (which I clean forgot to send to the list). As a matter of fact, my testing environment on my home machine is a little strange. I run the script from a RAID drive formated as ext3 but the data that the cgi has to work on, are on an ext2 partition on the same drive. I have the sneaky feeling ..... I'll test this within the next couple of days. > > 2) Are you doing this in mod-perl? If so, it's perhaps possible that > one or more variables isn't being cleared out when you hit the page > the second time. In the simple example above this is less likely, > but if it's just a "for example case" then perhaps this is the problem. > You might want to try giving everything a defined scope, and using > variables to hold the directory name: > > #!/usr/bin/perl -w > > use strict; > my $path = "/tmp"; > > { > # scoped to ensure limited lifetime > my $dir; > opendir($dir, $path) || die("Cannot opendir: $!"); > foreach my $entry (readdir($dir)) { > print "$entry\n"; > } > } Right ... I think I see what you mean. Except that I'm not running it in mod-perl. > Please let us know the results! Will do. Thanks. ciao -- the order of the links was changed but the chain remained a chain. Gianni Rodari #################################################################### Dr. Giancarlo Contrafatto School of Life and environmental Sciences University of Natal, 4041, Durban, RSA Tel: +27 031 2603336 contrafa@biology.und.ac.za #################################################################### visit Darwin at http://contra.biology.und.ac.za/ From contrafa at biology.und.ac.za Tue Aug 12 02:41:52 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] Behaviour of opendir: continued Message-ID: <1060673994.6270.29.camel@contra> Hi; right ... it looks like Oskar was correct. Running opendir (and readdir) from ext3 environment on data sitting in an ext2 drive is not the cause of opendir weirdness. Not a major problem since I can get the script to work by using another perlfunc anyway. Not knowing the innards of the opendir function, though, makes it a bit difficult to figure why it should do this. I'm now wondering if opendir may not be making a "findfile" system call, or something that looks into the file database anyway. In this case, I suspect that one may have to refresh the file database after creating new directory entries. How does this smell? ciao -- if you wish to savour your virtues, commit a sin from time to time. Ugo Ojetti #################################################################### Dr. Giancarlo Contrafatto School of Life and environmental Sciences University of Natal, 4041, Durban, RSA Tel: +27 031 2603336 contrafa@biology.und.ac.za #################################################################### visit Darwin at http://contra.biology.und.ac.za/ From WKruse at multichoice.co.za Tue Aug 12 06:58:21 2003 From: WKruse at multichoice.co.za (Walter Kruse) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] flat file test script Message-ID: <79A1791707CB084A8F5B8C5C2F8B06DE01FE709C@rnbm-msg02.mck.co.za> Hi everyone - hope someone will help a newbie I need to simulate the importing of a flat file into two tables in a db for test purposes. The file has very long records, which aren't separated into fields by any character. Rather, the program under test counts characters. So chars 1-8 go in table 1, chars 9-12 to table 2, chars 13-40 to table 1 again and so on. I want to use a perl script as the records are very long (+/- 88 fields) to create two new text files and sort the records between the two files as I specify. The problem, I am faced with, however, is the counting and sorting of the chars. I don't have a clue. This is as far as I got: #!/usr/bin/perl open (FILE, "testfile") || die "Can't open file !\n"; @file = ; my($record) = split(/\n/, @file); foreach $record (@file) { my($char) = split(//, $record); } close FILE; Kind Regards Walter Kruse MultiChoice Information Technology Software test analyst - Application Delivery and Support Team Tel: +27 (0) 11 289-4552 Cell: +27 (0) 82 660 7288 Email: walterk@multichoice.co.za Personal web page: http://www.ou-ryperd.net ************************************************************************************************************************** Everything in this e-mail and attachments relating to the official business of MultiChoice Africa is proprietary to the company. Any view or opinion expressed in this message may be the view of the individual and should not automatically be ascribed to the company. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify the sender immediately by email, facsimile or telephone and destroy the original message. ************************************************************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030812/0dcc0308/attachment.htm From mh2 at isis.co.za Tue Aug 12 16:17:12 2003 From: mh2 at isis.co.za (Mark Hewitt) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] flat file test script References: <79A1791707CB084A8F5B8C5C2F8B06DE01FE709C@rnbm-msg02.mck.co.za> Message-ID: <00a801c36117$1a3e52e0$2200a8c0@sswindev> Hi, Its pretty late (after 23:00!!) and I still have alot of work to complete before tomorrow, so I'll just make breif comments, I'll try respond in more detail tomorrow if I get a free moment. Pls find my comments in the original text... >>----- Original Message ----- >>From: Walter Kruse >>To: za-pm@mail.pm.org >>Sent: Tuesday, August 12, 2003 1:58 PM >>Subject: [Za-pm] flat file test script >>Hi everyone - hope someone will help a newbie >>I need to simulate the importing of a flat file into two tables in a db for test purposes. The file has very long records, which aren't separated into fields >>by any character. Rather, the program under test counts characters. So chars 1-8 go in table 1, chars 9-12 to table 2, chars 13-40 to table 1 again and so >>on. I want to use a perl script as the records are very long (+/- 88 fields) to create two new text files and sort the records between the two files as I Okay, a couple of points: 1. The example above puzzles me, as I would have expected the umbers of chars goin into each table to be the same each time? Or do you have 88 fields be "record", where the 88 get split between the 2 dbs, after reading all 88, the script can now process "record 2" in flat file? 2. What do you mean by "db"? Another flat file, or a real SQL database? >>specify. The problem, I am faced with, however, is the counting and sorting of the chars. I don't have a clue. This is as far as I got: Try substr or unpack. From your desription, many fields of specified length this sounds like a job for unpack. The Perl CookBook has a very useful function called cut2fmt() or something, it takes "cut-off" values as parameters, and returns the unpack format string required to unpack in that format. In your case, the unpack would begin like: @a = unpack( "A8 A4 A27"); You may want to generate this string programatically is you have 88 fields to go in the unpack! >>.#!/usr/bin/perl >>open (FILE, "testfile") || die "Can't open file !\n"; >>@file = ; >>my($record) = split(/\n/, @file); This is not needed, you destroy the content on $record in the next statement, and the entire file content is already broken into lines by the @file = statement. >>foreach $record (@file) >>{ >> my($char) = split(//, $record); # You'll want to use substr/unpack here, followed by the write to the database @a = unpack( "A8 A4 A27"); # this loop iterates over all parameters in the last extraction and writes them alternatly (as you showed in ur example) to the databases # its scalable like this and will handle any number of fields in the unpack token $i = 0; foreach $a (@a) { if ( $i++ & 1 ) { # add $a to database 1 } else { # add $a to database 2 } } >>} >>close FILE; Does this help you at all? Thanks, Mark ---------------------------------------------------------------------------- Windows, Linux and Internet Development Consultant Email: corporate@scriptsmiths.com Web: http://www.scriptsmiths.com Cell: +27 82 9655295 --------------------------------------------------------------------------- >>Kind Regards >>Walter Kruse >>MultiChoice Information Technology >>Software test analyst - Application Delivery and Support Team >>Tel: +27 (0) 11 289-4552 >>Cell: +27 (0) 82 660 7288 >>Email: walterk@multichoice.co.za >>Personal web page: http://www.ou-ryperd.net >>********************************************************************************************************************* >>Everything in this e-mail and attachments relating to the official business of MultiChoice Africa is proprietary to the company. Any >>view or opinion expressed in this message may be the view of the individual and should not automatically be ascribed to the >>company. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or copy this message. If you have >>received this message in error, please notify the sender immediately by email, facsimile or telephone and destroy the original >>message. >>********************************************************************************************************************* ------------------------------------------------------------------------------ _______________________________________________ Za-pm mailing list Za-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/za-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030812/d4472b27/attachment.htm From mh2 at isis.co.za Wed Aug 13 01:02:32 2003 From: mh2 at isis.co.za (Mark Hewitt) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] flat file test script Message-ID: <9764B5DBEDB6D4118ED20000F8004C33022AE8FF@IS240.isis.co.za> There seems to be a syntax error though, at least in Perl 5.8? See comments in the body.... >>-----Original Message----- >>vFrom: Walter Kruse [SMTP:WKruse@multichoice.co.za] >>Sent: 13 August, 2003 07:47 >>To: Mark Hewitt; za-pm@mail.pm.org >>Subject: RE: [Za-pm] flat file test script >>Hi Mark >>sorry, I did not make myself very clear. I don't know if everyone that posts >>get a message saying the moderator has to approve the post (apparently I am >>not a member), hence the post was received so late. > No problem > >> I am simulating the import of the file into Oracle, in order to compare my >>2 new files with what the tables in Oracle are populated with. This is to >>see that the program (under test) that splits the file and populates the >>tables, did its work correctly. Little complicated. Anyhoo, I now have a >>working hack that is good enough for me to use. Here it is: > >>#!/usr/bin/perl >>open (FILE, "testfile\.txt") || die "Can't open input file !\n"; >>@file = ; > >>open (FILEONE, ">fileone\.txt") || die "Can't create file one !\n"; >>open (FILETWO, ">filetwo\.txt") || die "Can't create file two !\n"; > >>my($record) = split(/\n/, @file); You can remove this line, it does nothing, because the already split the file by newlines, and the result of the split is being stored in a scalar anyways, hence all lines except first would be lost. >>foreach $record (@file) >>{ >> my(@char) = split(//, $record); >> foreach $char ($record) This is odd to me? $record contains the text of that particular line of the file we are in? It is not even an array? I would actually guess the foreach is not required, as the code below works on fixed indexes into @char, hence making no use of the fact that we are in a loop? >> { >> print FILEONE ("@char[0]","~","@char[2]","~","@char[4]@char[6]","~","@char[8]@char[10]@cha r[12]","~","@char[14]\n"); >> print FILETWO ("@char[1]@char[3]@char[5]","~","@char[7]","~","@char[9]@char[11]","~","@cha r[13]@char[15]\n"); Odd syntax? @char[0]? I would have thought the normal array indexer would be better? print FILEONE ("$char[0]","~","$char[2]","~","$char[4]$char[6]","~","$char[8]$char[10]$cha r[12]","~","$char[14]\n"); It also fixed the syntax error: >>D:\doc_root>perl -c test.pl >>In string, @cha now must be written as \@cha at test.pl line 15, near "]@cha" >>test.pl had compilation errors.. >> } >>} >>close FILEONE; >>close FILETWO; >>close FILE; >>print ("Done !\n\a") && die; Thanks, Mark >>krgds >>Walter Kruse > -----Original Message----- > From: Mark Hewitt [mailto:mh2@isis.co.za] > Sent: 12 August 2003 11:17 > To: za-pm@mail.pm.org > Subject: Re: [Za-pm] flat file test script > > > Hi, > > Its pretty late (after 23:00!!) and I still have alot of work to complete > before tomorrow, so I'll just make breif comments, I'll try respond in > more > detail tomorrow if I get a free moment. Pls find my comments in the > original > text... > > > >>----- Original Message ----- > >>From: Walter Kruse > >>To: za-pm@mail.pm.org > >>Sent: Tuesday, August 12, 2003 1:58 PM > >>Subject: [Za-pm] flat file test script > > >>Hi everyone - hope someone will help a newbie > >>I need to simulate the importing of a flat file into two tables in a db > for test purposes. The file has very long records, which aren't separated > into fields >>by any character. Rather, the program under test counts > characters. So chars 1-8 go in table 1, chars 9-12 to table 2, chars 13-40 > to table 1 again and so > >>on. I want to use a perl script as the records are very long (+/- 88 > fields) to create two new text files and sort the records between the two > files as I > > Okay, a couple of points: > 1. The example above puzzles me, as I would have expected the umbers of > chars goin into each table to be the same each time? Or do you have 88 > fields be "record", where the 88 get split between the 2 dbs, after > reading > all 88, the script can now process "record 2" in flat file? > 2. What do you mean by "db"? Another flat file, or a real SQL database? > > >>specify. The problem, I am faced with, however, is the counting and > sorting of the chars. I don't have a clue. This is as far as I got: > > Try substr or unpack. > >From your desription, many fields of specified length this sounds like a > job > for unpack. > The Perl CookBook has a very useful function called cut2fmt() or > something, > it takes "cut-off" values as parameters, and returns the unpack format > string required to unpack in that format. In your case, the unpack would > begin like: > > @a = unpack( "A8 A4 A27"); > > You may want to generate this string programatically is you have 88 fields > to go in the unpack! > > >>.#!/usr/bin/perl > >>open (FILE, "testfile") || die "Can't open file !\n"; > >>@file = ; > > >>my($record) = split(/\n/, @file); > > This is not needed, you destroy the content on $record in the next > statement, and the entire file content is already broken into lines by the > @file = statement. > > >>foreach $record (@file) > >>{ > > >> my($char) = split(//, $record); > > # You'll want to use substr/unpack here, followed by the write to the > database > > @a = unpack( "A8 A4 A27"); > > > # this loop iterates over all parameters in the last extraction and writes > them alternatly (as you showed in ur example) to the databases > # its scalable like this and will handle any number of fields in the > unpack > token > $i = 0; > foreach $a (@a) > { > if ( $i++ & 1 ) > { > # add $a to database 1 > } > else > { > # add $a to database 2 > } > } > > >>} > >>close FILE; > > > Does this help you at all? > > Thanks, > Mark > -------------------------------------------------------------------------- > -- > Windows, Linux and Internet Development Consultant > Email: corporate@scriptsmiths.com > Web: http://www.scriptsmiths.com > Cell: +27 82 9655295 > -------------------------------------------------------------------------- > - > > > >>Kind Regards > >>Walter Kruse > >>MultiChoice Information Technology > >>Software test analyst - Application Delivery and Support Team > >>Tel: +27 (0) 11 289-4552 > >>Cell: +27 (0) 82 660 7288 > >>Email: walterk@multichoice.co.za > >>Personal web page: http://www.ou-ryperd.net > > > >>************************************************************************ > ** > ******************************************* > >>Everything in this e-mail and attachments relating to the official > business of MultiChoice Africa is proprietary to the company. Any >>view > or > opinion expressed in this message may be the view of the individual and > should not automatically be ascribed to the >>company. If you are not the > intended recipient, you may not peruse, use, disseminate, distribute or > copy > this message. If you have >>received this message in error, please notify > the sender immediately by email, facsimile or telephone and destroy the > original >>message. > >>************************************************************************ > ** > ******************************************* > > > > _____ > > > > > _______________________________________________ > > > > > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > > > ************************************************************************** > ************************************************ > Everything in this e-mail and attachments relating to the official > business of MultiChoice Africa is proprietary to > the company. Any view or opinion expressed in this message may be the view > of the individual and should not automatically > be ascribed to the company. If you are not the intended recipient, you > may not peruse, use, disseminate, distribute or > copy this message. If you have received this message in error, please > notify the sender immediately by email, facsimile > or telephone and destroy the original message. > ************************************************************************** > ************************************************ << File: ATT00042.htm >> "DISCLAIMER: This e-mail and its attachments may contain information that is confidential and that may be subject to legal privilege and copyright. If you are not the intended recipient you may not peruse, use, disclose, distribute, copy or retain this message. If you have received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and return and thereafter destroy the original message.Please note that e-mails are subject to viruses, data corruption, delay, interception and unauthorised amendment, and that the sender does not accept liability for any damages that may be incurred as a result of communication by e-mail. No employee or intermediary is authorised to conclude a binding agreement on behalf of the sender by e-mail without express written confirmation by a duly authorised representative of the sender. By transmitting this e-mail message over the Internet the sender does not intend to allow the contents hereof to become part of the public domain, and the confidential nature of the contents shall not be altered or diminished from by such transmission." From WKruse at multichoice.co.za Wed Aug 13 00:47:21 2003 From: WKruse at multichoice.co.za (Walter Kruse) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] flat file test script Message-ID: <79A1791707CB084A8F5B8C5C2F8B06DE01FE70A0@rnbm-msg02.mck.co.za> Hi Mark sorry, I did not make myself very clear. I don't know if everyone that posts get a message saying the moderator has to approve the post (apparently I am not a member), hence the post was received so late. I am simulating the import of the file into Oracle, in order to compare my 2 new files with what the tables in Oracle are populated with. This is to see that the program (under test) that splits the file and populates the tables, did its work correctly. Little complicated. Anyhoo, I now have a working hack that is good enough for me to use. Here it is: #!/usr/bin/perl open (FILE, "testfile\.txt") || die "Can't open input file !\n"; @file = ; open (FILEONE, ">fileone\.txt") || die "Can't create file one !\n"; open (FILETWO, ">filetwo\.txt") || die "Can't create file two !\n"; my($record) = split(/\n/, @file); foreach $record (@file) { my(@char) = split(//, $record); foreach $char ($record) { print FILEONE ("@char[0]","~","@char[2]","~","@char[4]@char[6]","~","@char[8]@char[10]@cha r[12]","~","@char[14]\n"); print FILETWO ("@char[1]@char[3]@char[5]","~","@char[7]","~","@char[9]@char[11]","~","@cha r[13]@char[15]\n"); } } close FILEONE; close FILETWO; close FILE; print ("Done !\n\a") && die; krgds Walter Kruse -----Original Message----- From: Mark Hewitt [mailto:mh2@isis.co.za] Sent: 12 August 2003 11:17 To: za-pm@mail.pm.org Subject: Re: [Za-pm] flat file test script Hi, Its pretty late (after 23:00!!) and I still have alot of work to complete before tomorrow, so I'll just make breif comments, I'll try respond in more detail tomorrow if I get a free moment. Pls find my comments in the original text... >>----- Original Message ----- >>From: Walter Kruse >>To: za-pm@mail.pm.org >>Sent: Tuesday, August 12, 2003 1:58 PM >>Subject: [Za-pm] flat file test script >>Hi everyone - hope someone will help a newbie >>I need to simulate the importing of a flat file into two tables in a db for test purposes. The file has very long records, which aren't separated into fields >>by any character. Rather, the program under test counts characters. So chars 1-8 go in table 1, chars 9-12 to table 2, chars 13-40 to table 1 again and so >>on. I want to use a perl script as the records are very long (+/- 88 fields) to create two new text files and sort the records between the two files as I Okay, a couple of points: 1. The example above puzzles me, as I would have expected the umbers of chars goin into each table to be the same each time? Or do you have 88 fields be "record", where the 88 get split between the 2 dbs, after reading all 88, the script can now process "record 2" in flat file? 2. What do you mean by "db"? Another flat file, or a real SQL database? >>specify. The problem, I am faced with, however, is the counting and sorting of the chars. I don't have a clue. This is as far as I got: Try substr or unpack. >From your desription, many fields of specified length this sounds like a job for unpack. The Perl CookBook has a very useful function called cut2fmt() or something, it takes "cut-off" values as parameters, and returns the unpack format string required to unpack in that format. In your case, the unpack would begin like: @a = unpack( "A8 A4 A27"); You may want to generate this string programatically is you have 88 fields to go in the unpack! >>.#!/usr/bin/perl >>open (FILE, "testfile") || die "Can't open file !\n"; >>@file = ; >>my($record) = split(/\n/, @file); This is not needed, you destroy the content on $record in the next statement, and the entire file content is already broken into lines by the @file = statement. >>foreach $record (@file) >>{ >> my($char) = split(//, $record); # You'll want to use substr/unpack here, followed by the write to the database @a = unpack( "A8 A4 A27"); # this loop iterates over all parameters in the last extraction and writes them alternatly (as you showed in ur example) to the databases # its scalable like this and will handle any number of fields in the unpack token $i = 0; foreach $a (@a) { if ( $i++ & 1 ) { # add $a to database 1 } else { # add $a to database 2 } } >>} >>close FILE; Does this help you at all? Thanks, Mark ---------------------------------------------------------------------------- Windows, Linux and Internet Development Consultant Email: corporate@scriptsmiths.com Web: http://www.scriptsmiths.com Cell: +27 82 9655295 --------------------------------------------------------------------------- >>Kind Regards >>Walter Kruse >>MultiChoice Information Technology >>Software test analyst - Application Delivery and Support Team >>Tel: +27 (0) 11 289-4552 >>Cell: +27 (0) 82 660 7288 >>Email: walterk@multichoice.co.za >>Personal web page: http://www.ou-ryperd.net >>************************************************************************** ******************************************* >>Everything in this e-mail and attachments relating to the official business of MultiChoice Africa is proprietary to the company. Any >>view or opinion expressed in this message may be the view of the individual and should not automatically be ascribed to the >>company. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or copy this message. If you have >>received this message in error, please notify the sender immediately by email, facsimile or telephone and destroy the original >>message. >>************************************************************************** ******************************************* _____ _______________________________________________ Za-pm mailing list Za-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/za-pm ************************************************************************************************************************** Everything in this e-mail and attachments relating to the official business of MultiChoice Africa is proprietary to the company. Any view or opinion expressed in this message may be the view of the individual and should not automatically be ascribed to the company. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify the sender immediately by email, facsimile or telephone and destroy the original message. ************************************************************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030813/d15e9b69/attachment.htm From WKruse at multichoice.co.za Wed Aug 13 03:48:45 2003 From: WKruse at multichoice.co.za (Walter Kruse) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] flat file test script Message-ID: <79A1791707CB084A8F5B8C5C2F8B06DE01FE70A6@rnbm-msg02.mck.co.za> Hi Mark all I changed was all the @char's to $char's (I see I still have a lot to learn), but the rest works 100% for me as is. No compile errors. I will post the final script just for interest's sake when I am done. Thank you very much for your help. krgds Walter Kruse -----Original Message----- From: Mark Hewitt [mailto:mh2@isis.co.za] Sent: 13 August 2003 08:03 To: 'za-pm@mail.pm.org' Cc: 'WKruse@multichoice.co.za' Subject: RE: [Za-pm] flat file test script There seems to be a syntax error though, at least in Perl 5.8? See comments in the body.... >>-----Original Message----- >>vFrom: Walter Kruse [SMTP:WKruse@multichoice.co.za] >>Sent: 13 August, 2003 07:47 >>To: Mark Hewitt; za-pm@mail.pm.org >>Subject: RE: [Za-pm] flat file test script >>Hi Mark >>sorry, I did not make myself very clear. I don't know if everyone that posts >>get a message saying the moderator has to approve the post (apparently I am >>not a member), hence the post was received so late. > No problem > >> I am simulating the import of the file into Oracle, in order to compare my >>2 new files with what the tables in Oracle are populated with. This is to >>see that the program (under test) that splits the file and populates the >>tables, did its work correctly. Little complicated. Anyhoo, I now have a >>working hack that is good enough for me to use. Here it is: > >>#!/usr/bin/perl >>open (FILE, "testfile\.txt") || die "Can't open input file !\n"; >>@file = ; > >>open (FILEONE, ">fileone\.txt") || die "Can't create file one !\n"; >>open (FILETWO, ">filetwo\.txt") || die "Can't create file two !\n"; > >>my($record) = split(/\n/, @file); You can remove this line, it does nothing, because the already split the file by newlines, and the result of the split is being stored in a scalar anyways, hence all lines except first would be lost. >>foreach $record (@file) >>{ >> my(@char) = split(//, $record); >> foreach $char ($record) This is odd to me? $record contains the text of that particular line of the file we are in? It is not even an array? I would actually guess the foreach is not required, as the code below works on fixed indexes into @char, hence making no use of the fact that we are in a loop? >> { >> print FILEONE ("@char[0]","~","@char[2]","~","@char[4]@char[6]","~","@char[8]@char[10]@cha r[12]","~","@char[14]\n"); >> print FILETWO ("@char[1]@char[3]@char[5]","~","@char[7]","~","@char[9]@char[11]","~","@cha r[13]@char[15]\n"); Odd syntax? @char[0]? I would have thought the normal array indexer would be better? print FILEONE ("$char[0]","~","$char[2]","~","$char[4]$char[6]","~","$char[8]$char[10]$cha r[12]","~","$char[14]\n"); It also fixed the syntax error: >>D:\doc_root>perl -c test.pl >>In string, @cha now must be written as \@cha at test.pl line 15, near "]@cha" >>test.pl had compilation errors.. >> } >>} >>close FILEONE; >>close FILETWO; >>close FILE; >>print ("Done !\n\a") && die; Thanks, Mark >>krgds >>Walter Kruse > -----Original Message----- > From: Mark Hewitt [mailto:mh2@isis.co.za] > Sent: 12 August 2003 11:17 > To: za-pm@mail.pm.org > Subject: Re: [Za-pm] flat file test script > > > Hi, > > Its pretty late (after 23:00!!) and I still have alot of work to complete > before tomorrow, so I'll just make breif comments, I'll try respond in > more > detail tomorrow if I get a free moment. Pls find my comments in the > original > text... > > > >>----- Original Message ----- > >>From: Walter Kruse > >>To: za-pm@mail.pm.org > >>Sent: Tuesday, August 12, 2003 1:58 PM > >>Subject: [Za-pm] flat file test script > > >>Hi everyone - hope someone will help a newbie > >>I need to simulate the importing of a flat file into two tables in a db > for test purposes. The file has very long records, which aren't separated > into fields >>by any character. Rather, the program under test counts > characters. So chars 1-8 go in table 1, chars 9-12 to table 2, chars 13-40 > to table 1 again and so > >>on. I want to use a perl script as the records are very long (+/- 88 > fields) to create two new text files and sort the records between the two > files as I > > Okay, a couple of points: > 1. The example above puzzles me, as I would have expected the umbers of > chars goin into each table to be the same each time? Or do you have 88 > fields be "record", where the 88 get split between the 2 dbs, after > reading > all 88, the script can now process "record 2" in flat file? > 2. What do you mean by "db"? Another flat file, or a real SQL database? > > >>specify. The problem, I am faced with, however, is the counting and > sorting of the chars. I don't have a clue. This is as far as I got: > > Try substr or unpack. > >From your desription, many fields of specified length this sounds like a > job > for unpack. > The Perl CookBook has a very useful function called cut2fmt() or > something, > it takes "cut-off" values as parameters, and returns the unpack format > string required to unpack in that format. In your case, the unpack would > begin like: > > @a = unpack( "A8 A4 A27"); > > You may want to generate this string programatically is you have 88 fields > to go in the unpack! > > >>.#!/usr/bin/perl > >>open (FILE, "testfile") || die "Can't open file !\n"; > >>@file = ; > > >>my($record) = split(/\n/, @file); > > This is not needed, you destroy the content on $record in the next > statement, and the entire file content is already broken into lines by the > @file = statement. > > >>foreach $record (@file) > >>{ > > >> my($char) = split(//, $record); > > # You'll want to use substr/unpack here, followed by the write to the > database > > @a = unpack( "A8 A4 A27"); > > > # this loop iterates over all parameters in the last extraction and writes > them alternatly (as you showed in ur example) to the databases > # its scalable like this and will handle any number of fields in the > unpack > token > $i = 0; > foreach $a (@a) > { > if ( $i++ & 1 ) > { > # add $a to database 1 > } > else > { > # add $a to database 2 > } > } > > >>} > >>close FILE; > > > Does this help you at all? > > Thanks, > Mark > -------------------------------------------------------------------------- > -- > Windows, Linux and Internet Development Consultant > Email: corporate@scriptsmiths.com > Web: http://www.scriptsmiths.com > Cell: +27 82 9655295 > -------------------------------------------------------------------------- > - > > > >>Kind Regards > >>Walter Kruse > >>MultiChoice Information Technology > >>Software test analyst - Application Delivery and Support Team > >>Tel: +27 (0) 11 289-4552 > >>Cell: +27 (0) 82 660 7288 > >>Email: walterk@multichoice.co.za > >>Personal web page: http://www.ou-ryperd.net > > > >>************************************************************************ > ** > ******************************************* > >>Everything in this e-mail and attachments relating to the official > business of MultiChoice Africa is proprietary to the company. Any >>view > or > opinion expressed in this message may be the view of the individual and > should not automatically be ascribed to the >>company. If you are not the > intended recipient, you may not peruse, use, disseminate, distribute or > copy > this message. If you have >>received this message in error, please notify > the sender immediately by email, facsimile or telephone and destroy the > original >>message. > >>************************************************************************ > ** > ******************************************* > > > > _____ > > > > > _______________________________________________ > > > > > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > > > ************************************************************************** > ************************************************ > Everything in this e-mail and attachments relating to the official > business of MultiChoice Africa is proprietary to > the company. Any view or opinion expressed in this message may be the view > of the individual and should not automatically > be ascribed to the company. If you are not the intended recipient, you > may not peruse, use, disseminate, distribute or > copy this message. If you have received this message in error, please > notify the sender immediately by email, facsimile > or telephone and destroy the original message. > ************************************************************************** > ************************************************ << File: ATT00042.htm >> "DISCLAIMER: This e-mail and its attachments may contain information that is confidential and that may be subject to legal privilege and copyright. If you are not the intended recipient you may not peruse, use, disclose, distribute, copy or retain this message. If you have received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and return and thereafter destroy the original message.Please note that e-mails are subject to viruses, data corruption, delay, interception and unauthorised amendment, and that the sender does not accept liability for any damages that may be incurred as a result of communication by e-mail. No employee or intermediary is authorised to conclude a binding agreement on behalf of the sender by e-mail without express written confirmation by a duly authorised representative of the sender. By transmitting this e-mail message over the Internet the sender does not intend to allow the contents hereof to become part of the public domain, and the confidential nature of the contents shall not be altered or diminished from by such transmission." ************************************************************************************************************************** Everything in this e-mail and attachments relating to the official business of MultiChoice Africa is proprietary to the company. Any view or opinion expressed in this message may be the view of the individual and should not automatically be ascribed to the company. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify the sender immediately by email, facsimile or telephone and destroy the original message. ************************************************************************************************************************** From chris at autobleep.com Wed Aug 20 03:54:22 2003 From: chris at autobleep.com (Chris Martinus) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] Reply to Karl Fischer - perl training Message-ID: <002201c366f8$a8c04000$03f25ec0@autobleep.com> Hi! I've just subscribed to the list and was scratching thru the archives and came across Karl's enquiry about perl training. I taught perl courses for several years at Io Systems (a company which is now dormant). However, if there is sufficient interest, I would be happy to revive the perl course. Let me know. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030820/2fc318bc/attachment.htm From chris at autobleep.com Wed Aug 20 04:12:39 2003 From: chris at autobleep.com (Chris Martinus) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] Micro-perl?? Message-ID: <003701c366fb$36a95f80$03f25ec0@autobleep.com> I actually stumbled onto this list while I was searching to see if anyone had come up with a tiny perl cross-compiler/interpreter for use with modern microcontrollers. Most of the development work I do these days is on Atmel micros which can have quite substantial amounts of memory (still measured in kilobytes :-( ). Development is usually done using GNU C. Perl's string handling, regular expressions and references would be really cool to speed development of reliable code - but there is no way Perl 5 could be shoehorned into a microcontroller! I was toying with the idea of perhaps using P2C - or else embarking on a project to strip down Perl 4 and squeeze a small interpreter into a microcontroller. Does anyone know if this wheel has already been invented? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030820/c8932de6/attachment.htm From nico at itfirms.co.za Wed Aug 20 13:38:33 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:40:01 2004 Subject: [Za-pm] Micro-perl?? In-Reply-To: <003701c366fb$36a95f80$03f25ec0@autobleep.com> References: <003701c366fb$36a95f80$03f25ec0@autobleep.com> Message-ID: <200308202038.34256.nico@itfirms.co.za> On Wednesday 20 August 2003 11:12, Chris Martinus wrote: > I actually stumbled onto this list while I was searching to see if anyone > had come up with a tiny perl cross-compiler/interpreter for use with modern > microcontrollers. > > Most of the development work I do these days is on Atmel micros which can > have quite substantial amounts of memory (still measured in kilobytes :-( > ). Development is usually done using GNU C. Perl's string handling, > regular expressions and references would be really cool to speed > development of reliable code - but there is no way Perl 5 could be > shoehorned into a microcontroller! > > I was toying with the idea of perhaps using P2C - or else embarking on a > project to strip down Perl 4 and squeeze a small interpreter into a > microcontroller. > > Does anyone know if this wheel has already been invented? No idea, but it would also do wonders for my old 486's. The biggest one has 8 MB RAM, and the other one 4 MB. It really is a tight fit, but as small as your env :) In the mean time, check out: Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load.