[23020] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5240 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 19 06:05:53 2003

Date: Sat, 19 Jul 2003 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 19 Jul 2003     Volume: 10 Number: 5240

Today's topics:
        Compiling and Installing Perl 5.8.0 on FreeBSD <rob@petitt.com>
    Re: crypt returns same string for different texts (David Efflandt)
        How can I delete files useing Perl <moneytea@xinhuanet.com>
    Re: Import - Read file <bwalton@rochester.rr.com>
    Re: JOIN problem ? (2nd attempt to post) (stu7)
    Re: JOIN problem ? (2nd attempt to post) (stu7)
        Perl Cookbook? <joec@aracnet.com>
    Re: Perl Cookbook? <bwalton@rochester.rr.com>
    Re: Perl Cookbook? <xern@cpan.org>
    Re: Perl Cookbook? <bigj@kamelfreund.de>
    Re: perlstyles <bik.mido@tiscalinet.it>
        Read the contents of a text file into an HTML page (Dutch3001)
    Re: Read the contents of a text file into an HTML page <usenet@dwall.fastmail.fm>
    Re: Read the contents of a text file into an HTML page <thecommissioner@hotmail.com>
    Re: Running CGI through browser from local hard disk <noreply@gunnar.cc>
    Re: Running CGI through browser from local hard disk <wsegrave@mindspring.com>
    Re: Running CGI through browser from local hard disk (Malcolm Dew-Jones)
    Re: s there a module to acess Micorsoft Access datafile <stanb@panix.com>
    Re: s there a module to acess Micorsoft Access datafile <bart.lateur@pandora.be>
        Secure module version <noreply@gunnar.cc>
        sinfo script, xchat, slackware <neosad1st@charter.net>
        Taint  Mode Newbie Help (sekdab)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 18 Jul 2003 20:45:19 -0700
From: "Rob Petitt" <rob@petitt.com>
Subject: Compiling and Installing Perl 5.8.0 on FreeBSD
Message-Id: <vhhfn726i03733@corp.supernews.com>

This is my first post here, so go easy! :-)

I get an error when attempting to install Perl 5.8.0 on FreeBSD that leaves
me completely clueless.

In file included from miniperlmain.c:26:
perl.h:3929: redefinition of `union semun'
*** Error code 1


This occurs early in the installation, after completing "sh Configure -de".
Running "make" gives this error.

Anyone else find (and solve) this?

Thanks!




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

Date: Sat, 19 Jul 2003 03:01:51 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: crypt returns same string for different texts
Message-Id: <slrnbhhd4v.maa.efflandt@typhoon.xnet.com>

On Thu, 17 Jul 2003 18:01:34 +0200, David Bouman <dbo@xbn.nl> wrote:
> Marshall Dudley wrote:
> 
>> I am having a problem where crypt is returning exactly the same
>> encrypted string for multiple input texts.  Does anyone know how to 
>> fix this?
>> 
>> Example:
>> 
>> $password1 = crypt "1058455513","SK";
>> $password2 = crypt "1058455539","SK";
>> $password3 = crypt "1058455589","SK";
>> $password4 = crypt "1058455500","SK";
>> print "passwords = $password1, $password2, $password3, $password4\n";
>> 
>> Result:
>> 
>> perl testcrypt.pl
>> passwords = SKQ6.yqTB9svk, SKQ6.yqTB9svk, SKQ6.yqTB9svk, SKQ6.yqTB9svk
> 
> While it's perfectly legal for crypt to produce the same result for
> differing inputs, your crypt might actually encrypt just the first 8
> characters here

Yes, with DES crypt only the first 8 characters are significant (not sure 
about MD5 crypt).  A password can have more characters for ease of 
remembering it, but extra characters are ignored.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 19 Jul 2003 17:22:18 +0800
From: "moneytea" <moneytea@xinhuanet.com>
Subject: How can I delete files useing Perl
Message-Id: <bfb2kd$271k$1@mail.cn99.com>

Hi,
   I am a newbie,I try to use this programs to delete files(OS is Linux)
----------------------------------------
# file DEL.pl
#!/usr/bin/perl
$readparse;
print "Content-type: text/html\n\n";
unlink "del_file";
----------------------------------------
I can execute this program in command line ( ./DEL.pl) then it works .and
the file "del_file"
was removed ,but when I put "DEL.pl" into the /usr/local/apache/cgi-bin/ ,It
do nothing.
I really do not understand.
I even try this : system ("rm -rf del_file") ,not work too!
this program has the popedom of root.
Can anyone help me ?
thanks




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

Date: Sat, 19 Jul 2003 02:40:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Import - Read file
Message-Id: <3F18AF65.6090309@rochester.rr.com>

ttnguyen wrote:

 ...
> I have been working with ColdFusion and DB2 for about 1 month.  I have a
> question and hope someone could me me with.
> "How can I import an excel file to DB2 table"?
 ...


> -Thien
 ...


And your Perl question is?  Oh, you want to do it with Perl, not 
ColdFusion?  Modules are your friend.  Check out:

    Win32::OLE (if you're on Windoze)
    DBI
    DBD::DB2
    DBD::Excel
    DBD::ODBC (if you're on Windoze)
    Spreadsheet::ParseExcel

-- 
Bob Walton



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

Date: 18 Jul 2003 18:14:24 -0700
From: stuseven@hotmail.com (stu7)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <d7dd90b0.0307181714.647d57b4@posting.google.com>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> advised...

> First of all, join() returns a scalar.  Why are you storing ONE scalar in
> an array?  It's not "wrong", it's just suspect.  I don't think you're
> doing what you think you're doing.
> 
> Second, you've left out the first argument to join(), which is the string
> with which to join the other strings.
> 
>   print join " -- ", qw( apple banana cherry );
>   # apple -- banana -- cherry

*** Ya... I had not read about this first argument to JOIN... 
*** thanks to pinyaj and the others who told me about overlooking this.
*** Saving to an array was my natural instinct, given the original
*** list of three... a simple scalar would certainly be a good
*** suggestion here instead.


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

Date: 18 Jul 2003 18:37:25 -0700
From: stuseven@hotmail.com (stu7)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <d7dd90b0.0307181737.75196557@posting.google.com>

*** Ahh yes, of course you are correct... I was seeing the
*** first and second elements of the three exchanged.  Thank
*** you also for explaining this to me so well !

"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in message news:<Xns93BBD63959D45asu1cornelledu@132.236.56.8>...
> stuseven@hotmail.com (stu7) wrote in 
> news:d7dd90b0.0307171634.6532ff1d@posting.google.com:
> 
> > +  (I posted this the other day, but it seems to have
> >  dissappeared).
> > 
> >      Using my older version of Perl (5.08 ?), the JOIN
> >  command produces what appears to be more like a HASH
> >  than the ordered list I fed it... for instance;
> > 
> >  @fruitz = join "apple","bananna","cherry" ;
> 
> Take a look at the documentation for join:
> 
>  join EXPR,LIST
>       Joins the separate strings of LIST into a single string with
>       fields separated by the value of EXPR, and returns that new
>       string. Example:
> 
>       $rec = join(':', $login,$passwd,$uid,$gid,$gcos,$home,$shell);
> 
>       Beware that unlike "split", "join" doesn't take a pattern as its
>       first argument. Compare "split".
> 
> you should see that join returns a single string in scalar context.
> 
> Now, the first argument to join is taken to be the field separator you 
> want to use. Hence:
> 
> my $fruitz = join "apple","bananna","cherry" ;
> print $fruitz;
> 
> yields:
> 
> banannaapplecherry
> 
> because you have told Perl you want to have banana and cherry separated 
> by apple.
> 
> Now, by assigning the return value of join to an array you are creating 
> an array with the single element "banannaapplecherry".
> 
> >   - more often, this would come out:  apple cherry bananna
> >  when printed ...
> 
> That sounds impossible to me.
> 
> >      That seems a little odd_ but really, my question is,
> >  IS this what the JOIN command always does, or is it fixed
> >  or changed in later versions of Perl, 5.6 or later ?
> 
> I don't see what needs to be fixed other than your code. If you just want 
> to join "apple","bananna" and "cherry" with no separators in between, use
> 
> join "", "apple","bananna","cherry" ;
> 
> Sinan.


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

Date: Fri, 18 Jul 2003 18:52:04 -0700
From: Joseph Cipale <joec@aracnet.com>
Subject: Perl Cookbook?
Message-Id: <3F18A444.23178541@aracnet.com>

Is there a book on Perl that has some code that is in generic enough 
form that it can be dropped into place? Similar to any of the C/C++
books on coding/algorithms.

Thanks in advance!
-- 
#----------------------------------------------------------#
#                "Don't fear the penguin!"                 #
#----------------------------------------------------------#
# Registered Linux user: #309247     http://counter.li.org #
#----------------------------------------------------------#


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

Date: Sat, 19 Jul 2003 02:44:39 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl Cookbook?
Message-Id: <3F18B07B.1060703@rochester.rr.com>

Joseph Cipale wrote:

> Is there a book on Perl that has some code that is in generic enough 
> form that it can be dropped into place? Similar to any of the C/C++
> books on coding/algorithms.
 ...

Yes.  It is called (get this!): Perl Cookbook.  See http://www.oreilly.com .

-- 
Bob Walton



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

Date: Sat, 19 Jul 2003 12:02:19 +0800
From: xern <xern@cpan.org>
To: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl Cookbook?
Message-Id: <Pine.LNX.4.33.0307191200540.2355-100000@realTao.org>

On Sat, 19 Jul 2003, Bob Walton wrote:

> Joseph Cipale wrote:
> 
> > Is there a book on Perl that has some code that is in generic enough 
> > form that it can be dropped into place? Similar to any of the C/C++
> > books on coding/algorithms.
> ...
> 
> Yes.  It is called (get this!): Perl Cookbook.  See http://www.oreilly.com .
> 

On coding and algorithms? You may refer to <Mastering Algorithms with Perl> 
pulished by O'Reilly too.




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

Date: Sat, 19 Jul 2003 02:53:41 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Perl Cookbook?
Message-Id: <pan.2003.07.19.00.44.28.484981@kamelfreund.de>

xern wrote at Sat, 19 Jul 2003 12:02:19 +0800:

>> > Is there a book on Perl that has some code that is in generic enough 
>> > form that it can be dropped into place? Similar to any of the C/C++
>> > books on coding/algorithms.
>> ...
>> 
>> Yes.  It is called (get this!): Perl Cookbook.  See http://www.oreilly.com .
>> 
> 
> On coding and algorithms? You may refer to <Mastering Algorithms with Perl> 
> pulished by O'Reilly too.

And in addition, there is <Computer Science & Perl Programming> again
published by O'Reilly.


Greetings,
Janek


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

Date: Sat, 19 Jul 2003 09:51:02 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: perlstyles
Message-Id: <i7thhv0io881jhqt41tbpqmn90o0cnen7p@4ax.com>

On 17 Jul 2003 21:54:08 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:

>I've lately come to use quotes, too. My reason is the syntax-highlighter
>of vim that marks hash-keys in the same color as strings only when they
>are enclosed in some pair of quotation marks. Otherwise they wont get
>colored at all.

<OT>
What bothers me about *my* editor[*] is its inability to tell blocks
from inline hash refs, but then "only perl can parse Perl" and even
perl needs some help in certain circumstances.

A simple minded solution might be based upon assuming hash ref if the
construct goes like '{ key => something...', but I still don't have
the basic skills to edit my editor's perl mode and it doesn't seem
that other users are interested in this issue...
</OT>


[*] No, it is neither emacs nor vim, and not a dedicated IDE. It's
jed...


Michele
-- 
# This prints: Just another Perl hacker,
seek DATA,15,0 and  print   q... <DATA>;
__END__


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

Date: 18 Jul 2003 22:34:24 -0700
From: mandygretahello@msn.com (Dutch3001)
Subject: Read the contents of a text file into an HTML page
Message-Id: <57c4bcf5.0307182134.78d05a86@posting.google.com>

Hello,
I was just wondering if it was possible to read the contents of a text
file on the server into a web page...

Basically what i want to do is:

1) Create an HTML page
2) Create a text file
3) Instead of editing the HTML, saving it then uploading it again I
want to be able to just edit the text file on the server
4) When the browser visits the web page, the HTML reads the contents
of the text file into a certian spot on the screen. I don't want it to
just display the text file, i want it to display the contents in a
pre-determined spot on the screen.

I was wondering if this was possible... without cgi or perl or complex
java applets... If this isn't possible with just HTML or javascript
then please tell me how i'd do it with cgi or perl...

thanks in advance!


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

Date: Sat, 19 Jul 2003 07:25:40 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Read the contents of a text file into an HTML page
Message-Id: <Xns93BD22DEA6EE9dkwwashere@216.168.3.30>

mandygretahello@msn.com (Dutch3001) wrote:

> I was just wondering if it was possible to read the contents of a text
> file on the server into a web page...
> 
> Basically what i want to do is:
> 
> 1) Create an HTML page
> 2) Create a text file
> 3) Instead of editing the HTML, saving it then uploading it again I
> want to be able to just edit the text file on the server
> 4) When the browser visits the web page, the HTML reads the contents
> of the text file into a certian spot on the screen. I don't want it to
> just display the text file, i want it to display the contents in a
> pre-determined spot on the screen.
> 
> I was wondering if this was possible... without cgi or perl or complex
> java applets... If this isn't possible with just HTML or javascript
> then please tell me how i'd do it with cgi or perl...

Sounds like you might want to use a wiki.  

See http://c2.com/cgi/wiki?WikiGettingStartedFaq for some information 
about wikis.

http://c2.com/cgi/wiki?WikiEngines has a list of wiki software in a 
variety of languages, including Perl.  I like UseMod Wiki, but YMMV.

Not that this has much to do with Perl...

-- 
David Wall


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

Date: Sat, 19 Jul 2003 19:58:57 +1000
From: "dj" <thecommissioner@hotmail.com>
Subject: Re: Read the contents of a text file into an HTML page
Message-Id: <3f191652$0$1206$afc38c87@news.optusnet.com.au>


"Dutch3001" <mandygretahello@msn.com> wrote in message
news:57c4bcf5.0307182134.78d05a86@posting.google.com...
> Hello,
> I was just wondering if it was possible to read the contents of a text
> file on the server into a web page...
>
> Basically what i want to do is:
>
> 1) Create an HTML page
> 2) Create a text file
> 3) Instead of editing the HTML, saving it then uploading it again I
> want to be able to just edit the text file on the server
> 4) When the browser visits the web page, the HTML reads the contents
> of the text file into a certian spot on the screen. I don't want it to
> just display the text file, i want it to display the contents in a
> pre-determined spot on the screen.
>
> I was wondering if this was possible... without cgi or perl or complex
> java applets... If this isn't possible with just HTML or javascript
> then please tell me how i'd do it with cgi or perl...
>
> thanks in advance!

html wont do it, and client side javascript wont do it.
typically it can be done with serverside includes, or some form of server
parsing e.g. mod_perl, php, asp.
it depends upon what is available on your webhost.
i guess one easy peasy option would be to use a frameset.

(omigod i never thought i would ever suggest frames to someone)




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

Date: Sat, 19 Jul 2003 03:39:44 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bfa7ts$cpusd$1@ID-184292.news.uni-berlin.de>

William Alexander Segraves wrote:
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
> news:bf9p2k$bs8pj$1@ID-184292.news.uni-berlin.de...
>> William Alexander Segraves wrote:
>>> IMO, testing from the command line is something the OP should
>>> be doing before deployment on a CGI server.
>> 
>> Why? If you direct the exception messages to the browser, which
>> is kind of natural when developing CGI scripts, personally I find
>> 'the CGI way' to be more convenient.
> 
> It appears to be a matter of personal preference.

Yep. That's apparently the case. No more arguing needed, right? ;-)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 18 Jul 2003 21:51:21 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bfabsg$ev2$1@slb4.atl.mindspring.net>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bfa7ts$cpusd$1@ID-184292.news.uni-berlin.de...
<snip>
> > It appears to be a matter of personal preference.
>
> Yep. That's apparently the case. No more arguing needed, right? ;-)

Indeed!

All the best.

Bill




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

Date: 18 Jul 2003 23:54:09 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <3f18eb11@news.victoria.tc.ca>

William Alexander Segraves (wsegrave@mindspring.com) wrote:
: "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
: news:3f186200@news.victoria.tc.ca...
: <snip>
: > I have never found that necessary.  It's true the headers are displayed at
: > the top, but otherwise they do not interfere with the html in any way I
: > have ever noticed.
: >

: ISTM we're not talking (writing) about the same scenario. While the headers
: cause no problems when served by a CGI server; they do cause problems when
: they are at the top of an HTML file that is opened with MSIE. That's why I
: commented out the header shortcut in the example I posted for the command
: line version of a working script.

: YMMV.

: Cheers.

: Bill Segraves

Something in our setups must be different then.

I have opened many files (i.e. local files, e.g. C:\try.htm) with MSIE of
various versions, and have not found that mime like headers at the top of
the file make any difference to the display, except as appearing as lines
of text at the top of the window. 



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

Date: Sat, 19 Jul 2003 03:08:43 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bfacnr$llh$1@reader1.panix.com>

In <bfa062$3rb$1@slb9.atl.mindspring.net> "William Alexander Segraves" <wsegrave@mindspring.com> writes:

>"Stan Brown" <stanb@panix.com> wrote in message
>news:bf9n42$f1b$1@reader1.panix.com...
>> In <bf9lhr$mv7$1@slb6.atl.mindspring.net> "William Alexander Segraves"
><wsegrave@mindspring.com> writes:
>>
>> >"Stan Brown" <stanb@panix.com> wrote in message
>> >news:bf9den$bom$1@reader1.panix.com...
>> >> I find myself with the eed to obtain some data stored in Microsoft
>Access
>> >> format files from a perl script ruinning on a FreebSD box.
>> >>
>> >> What's the best way to do this?
>>
>> >Win32::ODBC
>>

>Stan, please note I retracted this statement, on seeing what appeared to be
>your objective.


Yep, but I only saw the first post before sending the question.


>>
>> Correct me if I'm wrong, but wouldn't that have to run on the Windows
>machine?
>>

>Yes. In addition, you'd have to set up a DSN on the Win32 machine to make it
>possible for Win32::ODBC to access the files. See
>http://www.roth.net/odbc/odbcfaq.htm for, well, FAQ stuff, on Win32.

>> Perhaps I did not mention, the idea is to not have to do any more to the
>> Windows box than mount it's share to get access to the files?
>>

>I understand. I wouldn't be at all surprised if you could do it that way. I
>just haven't done it myself.

>> Or am I on the wrong track here? I certainly will be the first to admit
>> that I know nothing about the Windows side of things!

>You may take a look at _Programming the Perl DBI_, Descartes, Alligator and
>Bunce, Tim, "ODBC from Perl", pp. 167-172 for how to move a Perl script that
>uses Win32::ODBC from Win32 to another platform.

>If you want to try setting up a Win32 box to provide access to MS Access
>files, you might try downloading and installing IndigoPerl, free from
>www.indigostar.com, on the Win32 box. Note that you don't need to have MS
>Access installed on the Win32 box to be able to access an MS Access file,
>although it would certainly be helpful, especially if you need to generate
>MS Access files for testing.

>A couple of interesting projects I've encountered that may be helpful to
>you:

>1. #GUFE: Generic but Usable Front End
>#by Aaron Weiss (aaron@pobox.com) for the Web Developers' Virtual Library
># http://www.wdvl.com

>2. # ODBC query - requires PERL 5.003_7 or higher and Win32::ODBC
># Author Alan Johnston - modified by WAS 11May2002
># Downloaded from http://www.roth.net/perl/scripts/scripts.asp?ODBCQry.pl

>I'd certainly *like* to be in your situation, as my preference, at times,
>would be to know as little as possible about Windows.

I works hard at it :-)


Thanks.

I'll check those out.





-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: Sat, 19 Jul 2003 08:09:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <jvuhhvcue69t0g8ndudi6ii0enpbs46fft@4ax.com>

Stan Brown wrote:

>I find myself with the eed to obtain some data stored in Microsoft Access
>format files from a perl script ruinning on a FreebSD box.
>
>What's the best way to do this?

Do it on a Windows box. :)

I'm sorry to say, but the MS Access file format is proprietary, and
undocumented. There's an interface built into all modern Windows
versions, so if you have one of those, you can access it.

Either you do it live (ODBC solution, see some DBI FAQs; or dbi-proxy
running on the Windows box), or you convert the data to a database which
you can use on FreeBSD.

   HTH,
   Bart.


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

Date: Sat, 19 Jul 2003 04:09:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Secure module version
Message-Id: <bfa9ld$bk8ni$1@ID-184292.news.uni-berlin.de>

I want to ensure that at least a certain version of a core module is 
used in a portable CGI script. Accordingly, a copy of that version is 
included in the distribution of my program, but if a later version is 
installed on the server, I would like that version to be used instead.

This is my first attempt to a resolution:

     my %tempinc = %INC;
     require Module;
     unless (eval { Module->VERSION(2.5) }) {
         %INC = %tempinc;
         unshift @INC, 'mylib';
         require Module;
     }

It should work as long as the script is run as a plain CGI script, but 
scarcely when the program is run under mod_perl.

Anybody who knows about a better way to accomplish the load of at 
least version X of a module, and that works also under mod_perl?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 18 Jul 2003 23:10:42 -0600
From: NeoSadist <neosad1st@charter.net>
Subject: sinfo script, xchat, slackware
Message-Id: <vhhklek8hg12cf@corp.supernews.com>

     Sorry to post about this, but i think it's related to the way perl
works.
     I have a problem with perl reading a file right when i make a call of
the script inside xchat.  It's the sinfo script.  I verified that the
output is wrong (i.e. read the file it's supposed to get the info from,
"cat /proc/meminfo").  However, I don't know perl much, although i'm
familiar with basic (so i'm not a complete moron lol).
     Here is the module in question.  Anyone, please help me get it working
right.  Your help will be "rewarded" by putting your name in the script and
on the website i'm going to offer the revision to.

sub mem {
        if (@resources){
                } else {
                        @resources = cat("/proc/meminfo");
                }
        
        $sysname = qx|uname -r|;
        if (substr($sysname,0,3) eq "2.4" || substr($sysname,0,3) eq "2.2"){
                @mem = split/\s+/,(grep{/Mem:/}@resources)[0];
                $memused = sprintf ("%.1f",($mem[2] - $mem[5] - $mem[6])/1030010);
                $memtotal = sprintf ("%.1f",($mem[1]/1030010));
                $memper = sprintf ("%.f",($memused/$memtotal)*100);

        } elsif (substr($sysname,0,3) eq "2.5" || substr($sysname,0,3) eq "2.6") {
                @memt = split/\s+/,(grep{/MemTotal:/}@resources)[0];    
                @memf = split/\s+/,(grep{/MemFree:/}@resources)[0];
                @memb = split/\s+/,(grep{/Buffers:/}@resources)[0];
                @memc = split/\s+/,(grep{/Cached:/}@resources)[0];
                        
                $memused = sprintf ("%.1f",($memt[1] - $memf[1] - $memb[1] -
$memc[1])/1024);
                $memtotal = sprintf ("%.1f",($memt[1]/1024));
                $memper = sprintf ("%.f",($memused/$memtotal)*100);
        }
        $final = ("$final$c1 Mem usage:$c2 $memused/$memtotal MB ($memper%) |");
}


And here's a copy of the file it's reading:

        total:    used:    free:  shared: buffers:  cached:
Mem:  1025478656 432230400 593248256        0 69070848 135581696
Swap: 82214912        0 82214912
MemTotal:      1001444 kB
MemFree:        579344 kB
MemShared:           0 kB
Buffers:         67452 kB
Cached:         132404 kB
SwapCached:          0 kB
Active:         138756 kB
Inactive:       177136 kB
HighTotal:       98304 kB
HighFree:         1540 kB
LowTotal:       903140 kB
LowFree:        577804 kB
SwapTotal:       80288 kB
SwapFree:        80288 kB


And here's a copy of the wrong output i get (inside xchat2.0.2):

| Mem Usage: 183.7/995.6 MB (18%) |

Someone, anyone, please help me.

-- 
" ... and are endowed by their Creator
with certain unalienable rights ... "
NeoSadist


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

Date: 19 Jul 2003 00:53:19 -0700
From: seldan@lore.cc (sekdab)
Subject: Taint  Mode Newbie Help
Message-Id: <4b21880f.0307182353.1e150296@posting.google.com>

Hello all.

I am teaching myself Perl and have written a CGI script that allows a
user to change his/her Apache password by calling "htaccess" in batch
mode via a set of backticks (intranet only!).

The script is running perfectly, however, I'd really like to place it
in taint mode so that I can learn the right way.  However, when I do
that, it breaks.  Here is a snippet where things go amiss:

$!/opt/perl/bin/perl -wT
use strict;
use CGI;
my $pass=$q->param("pass");
my $pass_ck=$q->param("pass_ck");
my $user=$q->remote_user;
my $pcmd='/opt/apache/bin/htpasswd -b';
my $auth='/usa/auth/passwd';
$ENV{PATH}='/usr/bin';

#... - Subroutines to Create HTML Snipped out - ...#

if ( $pass && $pass_ck ) {
   if ( $pass eq $pass_ck ) {
      if ( $pass =~ /^[A-Za-z0-9]+$/ ) {
         $pass = $1;
         my $output=`$pcmd $auth $user $pass 2>&1`;	
         chomp($output);
         if ( $output eq "Updating password for user $user" ) {
            print "PASSWORD CHANGE OKAY";
         } else {
            print "ERROR CHANGING PASSWORD";
         }
      } else {
         print "PASSWORD FAILED - NON ALPHANUMERIC";
      }
   } else {
   print "PASSWORDS DO NOT MATCH";
   }
}

The form is basically, "enter new password," "enter new password
again," and "submit."  So, first I ensure that the passwords entered
are not null, and then verify that they match.  After that (the third
if) I try to untaint the $pass variable.

I check to ensure that it is alphanumeric and then assign it to $1. 
After which, I place it in the shell execution backticks.  However,
both $1 and $pass are null now, and the execution fails.

The error coming from Perl is:

"Use of uninitialized value in concatenation (.) or string at
/usa/perl/change_pass.pl line 67."

That line is where I declare and set $ouput (i.e. the backtick
execution).

I'm stumped.  I really want to learn this the right way first time
around and get things working with taint.  I love the concept behind
it, just having trouble with the implementation.

My appreciation for any assistance,
Tom


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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 5240
***************************************


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