[19083] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1278 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 11 03:42:02 2001

Date: Wed, 11 Jul 2001 00:41:40 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <994837300-v10-i1278@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 11 Jul 2001     Volume: 10 Number: 1278

Today's topics:
        Perl Newbie - problem with NTFS and readdir <quimby72@my-deja.com>
    Re: Perl Newbie - problem with NTFS and readdir <mdufault@dynamicservers.com>
        Perl Project (Dave Goldstein)
        Perl solution comparable to PHP Nuke? <Anan@hotmail.com>
    Re: Perl solution comparable to PHP Nuke? <laszlo.gerencser@portologic.com>
    Re: Perl vs. PHP for CGI in the long-run <pr_NOSPAM_lx@m*NOSPAM*ac.com>
        Perl will only work by double clicking script it won't  (ridelightning)
    Re: Perl will only work by double clicking script it wo <pne-news-20010709@newton.digitalspace.net>
        Perl2Exe experiences (Carsten Wich)
    Re: Perl2Exe experiences <newspost@coppit.org>
    Re: Perl2Exe experiences <kevin@vaildc.net>
    Re: Perl2Exe experiences <newspost@coppit.org>
        perlscript won't function when activated through cronta rik@tidi.be
    Re: perlscript won't function when activated through cr <gnarinn@hotmail.com>
    Re: perlscript won't function when activated through cr (Rafael Garcia-Suarez)
    Re: perlscript won't function when activated through cr rik@tidi.be
    Re: perlscript won't function when activated through cr rik@tidi.be
    Re: perlscript won't function when activated through cr (Eric Bohlman)
    Re: perlscript won't function when activated through cr <time4tea@monmouth.com>
        ping problem <lwalker@ecn.purdue.edu>
    Re: ping problem (Martien Verbruggen)
        Problem formatting with @* (multiline field) (Beerus Maximus)
    Re: Problem formatting with @* (multiline field) <bwalton@rochester.rr.com>
    Re: problem with data.. <ddunham@redwood.taos.com>
    Re: problem with data.. <ddunham@redwood.taos.com>
    Re: problem with data.. <iltzu@sci.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 09 Jul 2001 11:07:40 -0400
From: "RobB" <quimby72@my-deja.com>
Subject: Perl Newbie - problem with NTFS and readdir
Message-Id: <20010709.110737.1766342842.30289@berkes.radiology.wisc.edu>

Hi,
very much new to perl, so I imagine I'm doing something wrong, and would
appreciate any help anyone can provide!
I am using perl on a dual boot Windows 2000 / Mandrake Linux system.
Perl version is 5.6.0.  
I am using it from Linux and attempting to read each file/directory in my
W2K "Documents and Settings/Favorites" folder.  The NTFS partition is
mounted to /mnt/nt,  using the "mount -t ntfs" command.
The problem I run across is that the last file in the directory is never
opened or processed.  I have tried copying the entire directory to my Linux ext2
filesystem, and that directory IS read in its entirety.   I have included
the effected code I'm using below.  
Since the directory is read fine from an ext2 filesystem, but not an NTFS
filesystem, it looks like a bug to me, but Im willing to bet it is just
due to my inexperience with perl.  Any help would be greatly appreciated!
Thanks,
Rob


sub process_directory { 
while ($direntry =  readdir (DRCTRY) )
{
    if ($direntry =~ m/url/) {
	print LOG "entry $direntry is a file\n";
	open (URLFILE, "$location/$direntry") || die print LOG "ABORTED. Error opening $direntry";
	while (<URLFILE>)
	{
	    chomp();
	    if ( ! /^URL.*/)
	    {next;}
	    
	    /(URL=)(.*)/;
	    $url = $2;
	    $direntry =~ s/\.url//;
	    print HTML "Description = <A HREF=$url> $direntry </A><BR>\n";
	}
         
	close (URLFILE);

    }
    else { print LOG "entry $direntry is NOT a file\n";
	   $unread_directories[$number_unread_directories] = "$location/$direntry";
	   $number_unread_directories ++;
	  }

 }   

}


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


------------------------------

Date: Mon, 09 Jul 2001 23:27:11 GMT
From: "Mark W. Dufault" <mdufault@dynamicservers.com>
Subject: Re: Perl Newbie - problem with NTFS and readdir
Message-Id: <j5r27.149574$v5.11395641@news1.rdc1.ct.home.com>

I think the curly brace after the close needs to be moved up before the
close (URLFILE);
I didn't bother to try it but it helps when you match up the braces with
indentations to see what matches the open braces.
I'm ne too so I may be off track...
"RobB" <quimby72@my-deja.com> wrote in message
news:20010709.110737.1766342842.30289@berkes.radiology.wisc.edu...
> Hi,
> very much new to perl, so I imagine I'm doing something wrong, and would
> appreciate any help anyone can provide!
> I am using perl on a dual boot Windows 2000 / Mandrake Linux system.
> Perl version is 5.6.0.
> I am using it from Linux and attempting to read each file/directory in my
> W2K "Documents and Settings/Favorites" folder.  The NTFS partition is
> mounted to /mnt/nt,  using the "mount -t ntfs" command.
> The problem I run across is that the last file in the directory is never
> opened or processed.  I have tried copying the entire directory to my
Linux ext2
> filesystem, and that directory IS read in its entirety.   I have included
> the effected code I'm using below.
> Since the directory is read fine from an ext2 filesystem, but not an NTFS
> filesystem, it looks like a bug to me, but Im willing to bet it is just
> due to my inexperience with perl.  Any help would be greatly appreciated!
> Thanks,
> Rob
>
>
> sub process_directory

> while ($direntry =  readdir (DRCTRY) )
> {
>     if ($direntry =~ m/url/) {
> print LOG "entry $direntry is a file\n";
> open (URLFILE, "$location/$direntry") || die print LOG "ABORTED. Error
opening $direntry";
> while (<URLFILE>)
> {
>     chomp();
>     if ( ! /^URL.*/)
>     {next;}
>
>     /(URL=)(.*)/;
>     $url = $2;
>     $direntry =~ s/\.url//;
>     print HTML "Description = <A HREF=$url> $direntry </A><BR>\n";
> }
>
> close (URLFILE);
>
>     }
>     else { print LOG "entry $direntry is NOT a file\n";
>    $unread_directories[$number_unread_directories] =
"$location/$direntry";
>    $number_unread_directories ++;
>   }
>
>  }
>
> }
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----




------------------------------

Date: 10 Jul 2001 13:00:02 -0700
From: dagoldst@aol.com (Dave Goldstein)
Subject: Perl Project
Message-Id: <8f6b80cf.0107101200.46bbc34c@posting.google.com>

Dear Fellow Programmer,
My name is Brett, and my company is Daveations. INC.  We have started
a new division in our company called Course Creation, and we have
already signed up with a lot of schools and big corporations.  We
really do project this will be huge, and we keep signing up with more
schools everyday.  What we are looking for is for an experienced
programmer of any languages, such as Perl,SQL, ASP and so forth to
write a course for us.  The courses will be sold, and you will receive
a nice
percentage of every sale.  We are projecting right now that 5-10 of
each course in each language will be sold per school.  And right now
we have 50 schools with it adding.  So we figure you will do very well
in this little project.  It isn't a long project and it is very
profitable.  If you would like to know more about this please feel
free to email me at any time with your questions and concerns. I look
forward to hearing from you, and I hopefully we can bring you on the
team.
Thank you for your time
Brett 
please email me Brett@Daveations.com


------------------------------

Date: Tue, 10 Jul 2001 01:54:25 -0400
From: "Anan" <Anan@hotmail.com>
Subject: Perl solution comparable to PHP Nuke?
Message-Id: <9ie5d6$3b8$1@slb1.atl.mindspring.net>

I am a beginner perl program and have been doing some cgi with it, and have
also ran into PHP nuke(which seems pretty cool for a pre-made setup).  I am
wondering if there is anything comparable to that made in Perl?  Or do I
have to reinvent the wheel(or switch languages)?  Thanks, Anan




------------------------------

Date: Tue, 10 Jul 2001 09:08:13 GMT
From: Laszlo Gerencser <laszlo.gerencser@portologic.com>
Subject: Re: Perl solution comparable to PHP Nuke?
Message-Id: <3B4AC638.D97B22E9@portologic.com>

Take a look at these:

http://www.openinteract.org/about
http://cog.sourceforge.net/
http://www.linux.org.uk/
http://slashcode.com/
http://spine.sourceforge.net/cgi-bin/index.pl 
http://www.symphero.net/ 
http://developer.akopia.com/cgi-bin/ic 
http://www.extropia.com/applications.html -
http://www.metadot.com/metadot/index.pl?iid=12006
http://allcommerce.sourceforge.net/ 


--
Laszlo Gerencser
PortoLogic Ltd.


------------------------------

Date: Mon, 09 Jul 2001 15:37:52 GMT
From: "R. Eranki" <pr_NOSPAM_lx@m*NOSPAM*ac.com>
Subject: Re: Perl vs. PHP for CGI in the long-run
Message-Id: <090720011139036328%pr_NOSPAM_lx@m*NOSPAM*ac.com>

In article <3t1jktc0fqe1absrc13prten28hrg9ie26@4ax.com>, Thomas Bätzler
<Thomas@Baetzler.de> wrote:

> On Mon, 09 Jul 2001, "R. Eranki" <pr_NOSPAM_lx@m*NOSPAM*ac.com> wrote:
> >What do you guys think of the future of Perl as a CGI language? I've
> >used Perl for a while, and have been (unfortunately) using PHP more
> >recently, simply because it's fast (although mod_perl should be only
> >slightly slower, correct?).
> 
> Is there a particular reason why you don't use both for whatever they
> do best? I prefer PHP for frontend stuff (i.e. where the HTML matters)
> and Perl whenever I need to do something that needs a bit of logic.
> 
> HTH,

Naw, just get emotional about languages I like. My main concern is that
it'll die a Pascal death (for web programming), and I'll have to use
PHP.


------------------------------

Date: 9 Jul 2001 13:06:20 -0700
From: ridelightning2000@yahoo.com (ridelightning)
Subject: Perl will only work by double clicking script it won't work when running it from the command line
Message-Id: <c48b2323.0107091206.a88783b@posting.google.com>

I have a strange one here.  The script will only run correctly when
double clicking in GUI (NT 4.0 server).  I have it scheduled using the
AT command but it doesn&#8217;t execute correctly.
Basically it creates an index for a search engine.  In the script
there is a line of code that assigns a variable a virtual directory.
Example:
&#8220;/inetpub/wwwroot/&#8221;
Well the actual path is d:/inetpub/wwwroot
I believe for some reason it&#8217;s looking for the directory on c:
If I create the same directory on c it runs fine.
Does anyone have a clue on how I can make it look on d???
Note:  I can&#8217;t just give it the actual path because it will
generate links with &#8220;d:/inetpub/wwwroot/somedirectory/file.html&#8221;
Oh and why does it work in GUI????????
Any help would be great.
Thanks
ride


------------------------------

Date: Mon, 09 Jul 2001 23:13:16 +0200
From: Philip Newton <pne-news-20010709@newton.digitalspace.net>
Subject: Re: Perl will only work by double clicking script it won't work when running it from the command line
Message-Id: <9g7kkto44mvtdsd1ae7nf20l98q3mg5u94@4ax.com>

On 9 Jul 2001 13:06:20 -0700, ridelightning2000@yahoo.com
(ridelightning) wrote:

> &#8220;/inetpub/wwwroot/&#8221;
> Well the actual path is d:/inetpub/wwwroot
> I believe for some reason it&#8217;s looking for the directory on c:
> If I create the same directory on c it runs fine.
> Does anyone have a clue on how I can make it look on d???

Looks like the script has the wrong idea of the current working
directory; if you double-click on the icon, it will presumably have the
directory that's displayed in Explorer as its Cwd, while when run with
AT, it may have C:\ or some random directory as its Cwd.

So change directory to a known place before you do relative stuff.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


------------------------------

Date: 10 Jul 2001 16:48:59 GMT
From: c_wich@river.prima.de (Carsten Wich)
Subject: Perl2Exe experiences
Message-Id: <slrn9kmcfr.3bt.c_wich@river.prima.de>

Hello Perl Freaks,

I am currently evaluating the commercial product Perl2Exe from
IndigoStar Software. So far everything sounds promising and my first
test programs seemed to work okay.

I am very interested in experiences from other users of this product
on Windows and/or Unix platforms, especially from one who has used it
in a productive environment for a longer period.

So, can anybody comment on Perl2Exe ? Problem, Bugs, Misbehaviours ?

Thanks, Carsten


------------------------------

Date: Tue, 10 Jul 2001 16:44:25 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Perl2Exe experiences
Message-Id: <3B4B6929.8090603@coppit.org>

Carsten Wich wrote:

> Hello Perl Freaks,


Hm... "Freaks"? Most people consider that an insult. Of course, you have 
to have a thick skin to be on this group. :)

 
> I am very interested in experiences from other users of this product
> on Windows and/or Unix platforms, especially from one who has used it
> in a productive environment for a longer period.
> 
> So, can anybody comment on Perl2Exe ? Problem, Bugs, Misbehaviours ?

I found 2 or 3 bugs, and the author either gave me a workaround or 
released a new version. (A couple of these issues are now in the docs.)

My only beef is that his reply to my latest bug was "upgrade to the 
5.6.0 version". Unfortunately, he doesn't have support for nearly as 
many platforms yet, so I'm not sure I want to shell out the extra $$ for 
the new version.

Support was speedy.

David



------------------------------

Date: Tue, 10 Jul 2001 18:15:45 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Perl2Exe experiences
Message-Id: <100720011815458889%kevin@vaildc.net>

In article <slrn9kmcfr.3bt.c_wich@river.prima.de>, Carsten Wich
<c_wich@river.prima.de> wrote:

> I am currently evaluating the commercial product Perl2Exe from
> IndigoStar Software. So far everything sounds promising and my first
> test programs seemed to work okay.
> 
> I am very interested in experiences from other users of this product
> on Windows and/or Unix platforms, especially from one who has used it
> in a productive environment for a longer period.

I've produced a few internal programs with it on Win32 with no
insurmountable problems...a couple of the problems were things I was
doing wrong, and their tech support pointed that out very tactfully.  A
couple of things were just issues that they helped me work around.  No
bugs to report.

You do have to be careful that every module that's used by your program
gets use'd or require'd somewhere, though.  This is all explained in
their documentation.  For most programs it probably isn't a big deal,
but for example Tk programs will attempt to require the module
associated with a widget at runtime if you haven't already included it;
this doesn't work in a compiled program.

-- 
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net   | blazing high above your head.
 . . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)


------------------------------

Date: Tue, 10 Jul 2001 21:47:02 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Perl2Exe experiences
Message-Id: <3B4BB016.9070801@coppit.org>

Oh yeah, if you plan to support your software for several platforms, be 
ready to wrestle with any compiled modules you might be using. You have 
to compile them on the target architectures and copy them to the right 
locations for perl2exe to find them correctly. I have some scripts to 
automate this process if you get to this point.

David



------------------------------

Date: Tue, 10 Jul 2001 12:42:04 +0200
From: rik@tidi.be
Subject: perlscript won't function when activated through crontab
Message-Id: <3B4ADBFC.7DA161F3@tidi.be>

Hi,

I'm trying to cath the modification date of a file.
when running a perl-script through crontab, the instruction:

@a=stat ("saldtran.hs");

doesn't work. @a is an empty array.
when running this script interatively, on the shell prompt,
I receive valid data in the @a-array.
I tried to change the permissions on the file chmod 777, but that didn't
help...

What's wrong?

regards

rik



------------------------------

Date: Tue, 10 Jul 2001 10:38:27 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: perlscript won't function when activated through crontab
Message-Id: <994761507.320555323734879.gnarinn@hotmail.com>

In article <3B4ADBFC.7DA161F3@tidi.be>,  <rik@tidi.be> wrote:
>Hi,
>
>I'm trying to cath the modification date of a file.
>when running a perl-script through crontab, the instruction:
>
>@a=stat ("saldtran.hs");
>
>doesn't work. @a is an empty array.

try printing $! for the error

>when running this script interatively, on the shell prompt,
>I receive valid data in the @a-array.
>I tried to change the permissions on the file chmod 777, but that didn't
>help...
>
>What's wrong?
>

Probably the current directory is not what you assume
Try using full path

gnari


------------------------------

Date: 10 Jul 2001 11:08:34 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: perlscript won't function when activated through crontab
Message-Id: <slrn9kloia.7mj.rgarciasuarez@rafael.kazibao.net>

rik@tidi.be wrote in comp.lang.perl.misc:
} Hi,
} 
} I'm trying to cath the modification date of a file.
} when running a perl-script through crontab, the instruction:
} 
} @a=stat ("saldtran.hs");
} 
} doesn't work. @a is an empty array.
} when running this script interatively, on the shell prompt,
} I receive valid data in the @a-array.
} I tried to change the permissions on the file chmod 777, but that didn't
} help...
} 
} What's wrong?

Probably the current working directory.
chdir() to the directory you want before performing the stat() call.

perldoc -f chdir

and don't forget the "or die..." in case the chdir fails (as with any
system call, but you know that).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: Tue, 10 Jul 2001 13:22:11 +0200
From: rik@tidi.be
Subject: Re: perlscript won't function when activated through crontab
Message-Id: <3B4AE563.F62B7202@tidi.be>

The problem is indeed the working directory.
I provided a full path, and now the script works ....

regards

rik

Rafael Garcia-Suarez wrote:

> rik@tidi.be wrote in comp.lang.perl.misc:
> } Hi,
> }
> } I'm trying to cath the modification date of a file.
> } when running a perl-script through crontab, the instruction:
> }
> } @a=stat ("saldtran.hs");
> }
> } doesn't work. @a is an empty array.
> } when running this script interatively, on the shell prompt,
> } I receive valid data in the @a-array.
> } I tried to change the permissions on the file chmod 777, but that didn't
> } help...
> }
> } What's wrong?
>
> Probably the current working directory.
> chdir() to the directory you want before performing the stat() call.
>
> perldoc -f chdir
>
> and don't forget the "or die..." in case the chdir fails (as with any
> system call, but you know that).
>
> --
> Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/



------------------------------

Date: Tue, 10 Jul 2001 13:23:05 +0200
From: rik@tidi.be
To: gnarinn@hotmail.com
Subject: Re: perlscript won't function when activated through crontab
Message-Id: <3B4AE599.E3CF9E71@tidi.be>

The problem is indeed the current directory.
I provided a full path, and now the script works ....

regards

rik

gnari wrote:

> In article <3B4ADBFC.7DA161F3@tidi.be>,  <rik@tidi.be> wrote:
> >Hi,
> >
> >I'm trying to cath the modification date of a file.
> >when running a perl-script through crontab, the instruction:
> >
> >@a=stat ("saldtran.hs");
> >
> >doesn't work. @a is an empty array.
>
> try printing $! for the error
>
> >when running this script interatively, on the shell prompt,
> >I receive valid data in the @a-array.
> >I tried to change the permissions on the file chmod 777, but that didn't
> >help...
> >
> >What's wrong?
> >
>
> Probably the current directory is not what you assume
> Try using full path
>
> gnari



------------------------------

Date: 10 Jul 2001 11:25:52 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: perlscript won't function when activated through crontab
Message-Id: <9ieoo0$cua$1@bob.news.rcn.net>

rik@tidi.be wrote:
> I'm trying to cath the modification date of a file.
> when running a perl-script through crontab, the instruction:
                             ^^^^^^^^^^^^^^^
> @a=stat ("saldtran.hs");

> doesn't work. @a is an empty array.

There probably isn't a saldtran.hs in the script's current working 
directory when it's being run as a cron job.

> when running this script interatively, on the shell prompt,
> I receive valid data in the @a-array.

Whereas when you run it from the shell, your current working directory is 
probably the one where the file's located.

> I tried to change the permissions on the file chmod 777, but that didn't
> help...

It wouldn't, since the script isn't seeing the file in the first place.

If you expect to run a program as a cron job or as a CGI script, you need 
to either have it chdir() itself into a known directory early on, or else 
use full absolute paths on all filenames.



------------------------------

Date: Tue, 10 Jul 2001 07:38:38 -0400
From: "James Richardson" <time4tea@monmouth.com>
Subject: Re: perlscript won't function when activated through crontab
Message-Id: <9iepkm$gjg$1@slb6.atl.mindspring.net>


"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn9kloia.7mj.rgarciasuarez@rafael.kazibao.net...
> rik@tidi.be wrote in comp.lang.perl.misc:
> } Hi,
> }
> } I'm trying to cath the modification date of a file.
> } when running a perl-script through crontab,

> and don't forget the "or die..." in case the chdir fails (as with any
> system call, but you know that).
>

Which of course will be no use at all, as the output from cron most often is
redirected to dev null to avoid all those pesky mail messages.

He could write diagnostic output to a file of course.....





------------------------------

Date: Tue, 10 Jul 2001 01:15:37 -0500
From: Laron Andrion Walker <lwalker@ecn.purdue.edu>
Subject: ping problem
Message-Id: <Pine.GSO.4.33.0107100115080.14874-100000@min.ecn.purdue.edu>

Hello, does anyone know why I can't get the follwing code to return the
number of new and total messeges in a pop3 mailbox...


@mes=$pop3->ping('lwalker');

print "\nyou have $mes[0] new messages\n";
print "\n you have $mes[1] total messages";


Thanks,

Laron




------------------------------

Date: Tue, 10 Jul 2001 06:39:02 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: ping problem
Message-Id: <slrn9kl8o7.4ot.mgjv@verbruggen.comdyn.com.au>

On Tue, 10 Jul 2001 01:15:37 -0500,
	Laron Andrion Walker <lwalker@ecn.purdue.edu> wrote:
> Hello, does anyone know why I can't get the follwing code to return the
> number of new and total messeges in a pop3 mailbox...
> 
> 
> @mes=$pop3->ping('lwalker');
> 
> print "\nyou have $mes[0] new messages\n";
> print "\n you have $mes[1] total messages";

Hard to tell. What is $pop3? A Net::POP3 object? Some other POP client
module object? And how did you create/initialise it? You did connect
and log in and stuff?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Hi, John here, what's the root
Commercial Dynamics Pty. Ltd.   | password?
NSW, Australia                  | 


------------------------------

Date: 9 Jul 2001 10:54:33 -0700
From: beerus@hushmail.com (Beerus Maximus)
Subject: Problem formatting with @* (multiline field)
Message-Id: <dc394f1e.0107090954.63bfcc1d@posting.google.com>

I have a perl CGI pulling the variables out of an HTML form and
formatting them into a nice little flat text file. I'm having problems
with @*, the multiline field formatting doodad. Text is being passed
from a TEXTAREA HTML input, a la:

<TEXTAREA ROWS=10 COLS=35 WRAP="physical" NAME="comments"></TEXTAREA>

Problem is when I use @* to format the contents passed to my script,
no linebreaks are appearing. So @* is one looooonng line, even if the
text input on the HTML page is wrapping when the user types it in.
I've tried using WRAP="virtual" and WRAP="physical" in my form, but
still no luck. @* compresses it all onto one looooong line. I've
looked through Learning Perl, Programming Perl  and done a web search
but can't find what I'm doing wrong.

Can someone offer me a suggestion?


------------------------------

Date: Tue, 10 Jul 2001 01:51:15 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Problem formatting with @* (multiline field)
Message-Id: <3B4A5FA9.8189E51@rochester.rr.com>

Beerus Maximus wrote:
> 
> I have a perl CGI pulling the variables out of an HTML form and
> formatting them into a nice little flat text file. I'm having problems
> with @*, the multiline field formatting doodad. Text is being passed
> from a TEXTAREA HTML input, a la:
> 
> <TEXTAREA ROWS=10 COLS=35 WRAP="physical" NAME="comments"></TEXTAREA>
> 
> Problem is when I use @* to format the contents passed to my script,
> no linebreaks are appearing. So @* is one looooonng line, even if the
> text input on the HTML page is wrapping when the user types it in.
> I've tried using WRAP="virtual" and WRAP="physical" in my form, but
> still no luck. @* compresses it all onto one looooong line. I've
> looked through Learning Perl, Programming Perl  and done a web search
> but can't find what I'm doing wrong.
 ...
Hmmm...is there any chance the information coming back from the browser
has a different line terminator than what your OS's version of Perl is
expecting?  You might try something like:

      $text=~s/[\012\015]+/\n/g;

if your text is in variable $text.  Then apply the format.  I assume
your program works fine when you test it offline, right?
-- 
Bob Walton


------------------------------

Date: Mon, 09 Jul 2001 17:01:45 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: problem with data..
Message-Id: <Zrl27.19$xi1.22092@news.pacbell.net>

James Coupe <james@zephyr.org.uk> wrote:
> In message <NUr17.152790$qv3.42719635@nnrp5-w.sbc.net>, Darren Dunham
> <ddunham@redwood.taos.com> writes
>>Anyone see what (if anything) I've done wrong here?

> Tangentially:

> Might I suggest that scp might be an equally valid method of doing this,
> which simply requires issuing the scp commands?  Laziness, impatience,
> hubris etc.  (And in my case, stupidity.)

Yes, but ssh was chosen specifically.

Right now I'm using 'tar' to send the files, but I don't want to use it
in the future.  Tar requires the files to exist on disk already.  I'd
rather use some sort of on-the-fly file serialization device.  

However, I can't think of one, so I'll have to write it myself.  I can't
do that first, so my initial program uses tar and a temporary directory.

In the future I will just be copying a datastream that does not exist on
disk.  scp won't be sufficient for that, so I might as well use ssh now
and get it right.

In addition, I'll have the use of the forward channel in ssh which will
be useful for my program in the future to control some behaviors on the
client.

I didn't specify all that in my first post, but that is why I'm not
using scp.
-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
          < How are you gentlemen!! Take off every '.SIG'!! >


------------------------------

Date: Mon, 09 Jul 2001 17:24:08 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: problem with data..
Message-Id: <YMl27.534$qr3.40218@news.pacbell.net>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>> The client does this...
>> 
>>    my $cmd = "tar cf - .";
>>    print "$version\n";
>>    print `$cmd`;
>> 
>> $version is just a text string to help the server validate the data.

> If data is "out of place" within the archive, there's the possibility
> that it's the tar command that's putting it in the wrong position in the
> first place.  Oh, and why do you capture the output and then send it on,
> rather than letting tar send to your STDOUT directly?

Because I'm using buffered STDOUT.  The version print would appear after
the data from the tar.

I can try turning on autoflush and swapping everything around.

>> The server opens a filehandle by calling ssh to client with a pipe.
>> 
>>     my $cmd = "$ssh -e none -n ${user}\@${host} $remote_cmd 2>&1";
>>     unless (open (SSH, "$cmd|"))
>>       {
>>         warn "$0: Could not open ssh connection to $host.\n";
>>           ...

> open to/from a pipe fails iff the fork fails; whether or not the command
> is there has little or no relevance.  For instance:
> 	open( FOO, "nosuchcommand|" )
> will usually succeed.  To test whether the command itself worked, you
> have to look at the return value of close. 

True.  The excerpt did show the check for the SSH close.  It also checks
the TAR close, which is how I first noticed the error.

>>     my $len;
>>     while ($len = read SSH, $buf, $blocksize)
>>       {
>>         if (!defined $len)

> How can $len be true, but not defined?  Oops :)

Good question.  That's not a useful test condition.  Since I pulled it
from previous code, I've got to go back and fix the other one, too.

> Personally, I would use sysread to grab the version string, then dup SSH
> over STDIN, then call system.

I may worry about that, but for now I've managed to convince myself that
the much simpler client is at fault.

It's either the tar itself, or the ssh screwing up.  I'm going to have
to actually count the bytes running through the client now and compare
them to what's received on the other side...

> Are all your errors from calvin?  Is it the same machinetype (unix vs
> dos) as the one your server is running on?  Consider what happens if you
> tar up a file on calvin, ftp it to the host, then try untaring it... if
> you use read/print, then perl is going to do CRLF conversions, while if
> you let tar handle its input and output itself, this isn't a problem.

It's all Solaris...  

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
          < How are you gentlemen!! Take off every '.SIG'!! >


------------------------------

Date: 9 Jul 2001 22:32:41 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: problem with data..
Message-Id: <994716094.5197@itz.pp.sci.fi>

First comment: try to think of more meaningful subject lines.
  
In article <NUr17.152790$qv3.42719635@nnrp5-w.sbc.net>, Darren Dunham wrote:
>I've written a simplistic client/server program that tars up some files
>and sends them over an ssh connection.  It works most of the time, but
 [snip]
>
>The client does this...
>
>   my $cmd = "tar cf - .";
>   print "$version\n";
>   print `$cmd`;

I've no idea if this is relevant, but I'd rather write that as:

  $| = 1;
  print "$version\n";
  system "tar cf - .";  # maybe even exec, if that's the last line


>The server opens a filehandle by calling ssh to client with a pipe. 
>
>    my $cmd = "$ssh -e none -n ${user}\@${host} $remote_cmd 2>&1";

Why 2>&1?  Any errors from the client are going to mess up your input
stream.  (Hey, that could be it!)  Just let STDERR go where it will.


 [snip]
>            warn "$0: read error occured: $!\n";
>            warn "$0: Skipping host $host.\n";
>            close (TAR);
>            close(SSH);
>            next HOST;

Why not check the return value of close() here?

 [snip]
>    close (SSH);
>    if ($?)
>      { warn "$0: Status from SSH close was $?: $!\n"; }
>    close(TAR);
>    if ($?)
>      { warn "$0: Status from TAR close was $?: $!\n"; }

Here you are checking for errors, but I don't think you're doing it
quite the way you're supposed to.  Try this instead:

  close SSH or warn "$0: Status from SSH close was $?: $!\n";
  close TAR or warn "$0: Status from TAR close was $?: $!\n";


Finally, just because I have it here, let me post my own perl-ssh-tar
backup script.  Note that this one only uses perl to set itself up, and
then exec()s ssh to do the real work:

  #!/usr/bin/perl -w
  use strict;

  chdir '/home/iltzu/bak';
  open STDERR, '>>backup.log' or die $!;
  warn "--> starting at ". scalar(localtime). "\n";

  my ($year, $mon, $day) = (localtime)[5,4,3];
  $year += 1900; $mon++;

  my $file = sprintf("backup-%04d%02d%02d-incr.tgz", $year, $mon, $day);
  die "File $file exists!\n" if -e $file;

  open STDOUT, ">$file" or die "Opening '$file' failed: $!\n";

  exec qw(ssh -n -e none server.example.com),
    'touch .last-backup-attempt '.
    '&& find www -type d -name "tmp" -prune '.
    '        -or -type f -newer .last-backed-up -print0 '.
    '    | tar -czf - -T - --null '.
    '&& mv .last-backup-attempt .last-backed-up'
    or die "exec failed: $!\n";

  __END__

I've set up two cron jobs to run this, one every midnight and one at
reboot.  The result is that the backup gets done every night, or the
next time the (desktop) system is turned on.  Any further calls that
day will see that the datestamped tarball exists and die immediately.

Every once in a while I do a "find -ls" to see which files have been
deleted, so that I won't have to bother restoring them when the shit
really hits the fan.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1278
***************************************


home help back first fref pref prev next nref lref last post