Re: checking groups on unix
Check out the stat function -- it returns a long list of info., which will be of use to you: perl -e ' @list=stat(.); foreach(@list){printf %o \n,$_;} ' The printf %o part prints the value in octal, which is what you're after. The 3rd value in the returned array $list[2] is the mode. on my linux box, I get this output: 1406 644042 40775 27 1046 12 0 4000 7316040631 7315775540 7315775540 1 4 The 3rd element is the mode...775. ls -ald . shows: drwxrwxr-x 23 mcauthor wheel2048 Jun 25 23:02 Hope this helps. perldoc -f stat will give you all the nitty gritty on the rest. Chances are good your script will return much more useful information than you initially thought! Matt --- PURMONEN, Joni [EMAIL PROTECTED] wrote: Hi ya, I need to check the group status on numerous files/directories, and haven't been able to fing out the best way to do it with perl. I simply need to see if some directories do not have certain group set on them. Can anyone give any pointers? Cheers, Joni Ps. I only have learning perl and some other fairly simple books which didn't seem to have anything useful in them __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Re: Net::Telnet
Here's some code that works well for us to bounce some apache instances across a cluster(obviously truncated). Notice how you stuff STDOUT from your remote call into an array that you print for output locally. This module rocks, and is (for us) blistering fast and super flexible. Also, I used Term::Readkey to prompt for (noecho) passwords so you don't have them sitting there in your code. foreach my $server (@cluster) { # Initialze the arrays to make sure they're not holding prev. values... my (@stop,@start); my $s=Net::Telnet-new(Host=$server,Input_log='telnet.txt') || die Problem: $!\n; my $stop=qq(\./$server\_stop.sh); my $start=qq(\./$server\_start.sh); ## Connection to telnet service on remote host $s-login(Name= $user, Password=$pass, Prompt='/root\@.*/', Timeout=8) || die $s-errmsg, \n; @stop=$s-cmd(String=$stop,Prompt='/matt\@.*/') or warn $s-errmsg ,\n; print Stopping $server: @stop\n; sleep 2; @start=$s-cmd(String=$start,Prompt='/matt\@.*/') or warn $s-errmsg ,\n; print Starting $server; sleep 1; print @start\n; } The tricky part for me was to match the prompt after the command executed. I consider myself to be decent with regexes (for a relative beginner) but I had to fiddle with it for a while to get it happy. Hope this helps, Matt --- Tom Yarrish [EMAIL PROTECTED] wrote: Hey all, Okay, I'm playing with Net::Telnet, and I've gotten to the point where I connect to the other machine. What I wanted to know is, can I run and interact with a program just using the cmd() part of that module? Or do I need to use another module to do that. Basically what I'm going is telnetting to a server, then running a program (perl scripts actually), then feeding it some options, and then exiting out of the program. Sort of like this (snipped) $session-cmd(/home/export/user/Xmenu.pl); $session-cmd(2); # This is fed to the Xmenu.pl program $session-cmd(1); # and this $session-cmd(y); # and this Thanks, Tom -- #!/usr/bin/perl -w # 526-byte qrpff, Keith Winstein and Marc Horowitz [EMAIL PROTECTED] # MPEG 2 PS VOB file on stdin - descrambled output on stdout # arguments: title key bytes in least to most-significant order $_='while(read+STDIN,$_,2048){$a=29;$c=142;if((@a=unxC*,$_)[20]48){$h=5; $_=unxb24,join,@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$/;$d= unxV,xb25,$_;$b=73;$e=256|(ord$b[4])9|ord$b[3];$d=$d8^($f=($t=255)($d 12^$d4^$d^$d/8))17,$e=$e8^($t($g=($q=$e147^$e)^$q*8^$q6))9 ,$_=(map{$_%16or$t^=$c^=($m=(11,10,116,100,11,122,20,100)[$_/16%8])110;$t ^=(72,@z=(64,72,$a^=12*($_%16-2?0:$m17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271)) [$_]^(($h=8)+=$f+(~$g$t))for@a[128..$#a]}print+xC*,@a}';s/x/pack+/g;eval __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
A Term::ReadKey question -- keep cursor put!
I'm trying something like: for ($i=0; $i10; $i++){print $i;} and have the numbers iterate in ONE PLACE at the cursor (i.e. print, then backspace, print the new number, etc). I'm having problems figuring this out. Any ideas? Thanks Matt __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/
Re: APACHE with MOD_PERL
I strongly recommend that you let mod_perl do the apache build for you. Just make sure it can find the src directory under apache. Here's a script that I use. Hasn't failed me yet, although YMMV as I'm doing this on Solaris and Linux, not HP-UX. Don't see why it would be significantly different, though. Some notes are included ** Use mod_perl to perform the apache build. To do this, create a script that passes various options to the build process. The following options we use and their meaning are: DO_HTTPD=1 tells mod_perl to do the apache build for you, skipping the interactive interface. USE_APACI=1 tells mod_perl to use the Apache AutoConf Interface. APACHE_PREFIX= /usr/local/apache installation path for apache. APACHE_SRC= /path/to/apache_x.xx.src tells mod_perl where to find the apache source. EVERYTHING=1 turns on all of mod_perls features. APACI_ARGS= -- option=value, --option=value, etc. passes additional arguments to apaches configure script. We use it to enable several modules at the time of the build. Create the script: perl Makefile.PL \r APACHE_PREFIX=/usr/local/apache \r APACHE_SRC=../apache_1.3.14/src \r DO_HTTPD=1 \r USE_APACI=1 \r EVERYTHING=1 \r APACI_ARGS='--enable-module=status --enable-module=speling --enable-module=rewrite --enable-module=auth_dbm' \r $1 Name it build_apache.sh and move into mod_perl directory. Now run the usual: sh ./build_apache.sh make make test Hope this is of some use to you and everyone else out there who has to do mod_perl installs. Btw, there is an EXCELLENT mod_perl book Writing Apache Modules in Perl and C by Lincoln Stein and Doug MacEachern (the writer of mod_perl). Most of my notes from the above were taken directly from the book. ~Matt C. --- [EMAIL PROTECTED] wrote: Hello, I will install apache_1.3.20.tar.gz and mod_perl-1.25.tar.gz on the HP-UX OS. I have installed all perl modules e.g libwww-perl-5.48.tar.gz URI MIME-Base64 HTML-Parser libnet Digest::MD5 HTML::Tagset Finally I am doing following: $gzip -d apache_x.xx.tar.gz $tar xfv apache_x.xx.tar $gzip -d mod_perl-x.xx.tar.gz $tar xfv mod_perl-x.xx.tar $cd mod_perl-x.xx $perl Makefile.PL EVERYTHING=1 $make $make test $make install $cd apache_x.xx $CC=cc CFLAGS=-Ae ./configure --prefix=/usr/local/apache $make $make install The make test doesn' t execute correct. I get the message cp t/conf/mod_perl_srm.conf t/conf/srm.conf /usr/local/software/apache_1.3.20/src/httpd -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t httpd listening on port 8529 will write error_log to: t/logs/error_log letting apache warm up...Syntax error on line 3 of /usr/local/software/mod_perl-1.25/t/conf/httpd.conf: Invalid command '=pod', perhaps mis-spelled or defined by a module not included in the server configuration done /usr/bin/perl t/TEST 0 still waiting for server to warm up...not ok server failed to start! (please examine t/logs/error_log) at t/TEST line 95. *** Error exit code 9 Stop. Thanks a lot for you help Best Regards Hasan -- Machen Sie Ihr Hobby zu Geld bei unserem Partner 11! http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: Similar mail lists for Linux/Unix??
Check out Linuxnewbie.org. A great site, in a similar vein as Perl Monks. Tons and tons of help there, and as the name implies it's geared toward promoting Linux and it's use to neophytes and intermediate folk like myself. ~Matt C. --- Tony Cook [EMAIL PROTECTED] wrote: On Wed, 23 May 2001 [EMAIL PROTECTED] wrote: Can anyone suggest mailing lists for Linux similar to this one? Perhaps your local Linux User Group runs a help list. -- Tony __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: Regrex question
$test=~ s/(dav)/$1 Smith/ig; print $test ; gives the following result: dav Smithe Dav Smithid Dav Smithy ### $test=~ s/(dav)w+/$1 Smith/ig; Gives us: dav Smith Dav Smith Dav Smith The \w+ says one or more word characters. Sticking that on the end gave us a bit more control over the result by matching ONLY dav . Also notice we didn't need the $regex= part, as you've already modified your string with the substitution. I'm sure some of the big guns out there will be able to tighten this up, but my advice is to be as specific as possible with regexes, and verbally go through them, i.e. the sring dav followed by one or more word characters, and so on. As for the number of matches, it looks to me like the expression $regex= ($test=~ s/(dav)/$1 Smith/ig); is actually forcing a scalar context on a list result (in perl's eye), which is giving you the number. I'm curious to see if this is correct, as I'm not 100% sure. Here's a small bit of back-up to my theory: #!/usr/bin/perl -W @test = qw (dave David Davy); # an array $scalar=@test; # an array evaluated in scalar context print This is scalar context: $scalar ; # output follows: This is scalar context: 3 As always, critiques are welcome with any of my posts... ~Matt C. --- David Gilden [EMAIL PROTECTED] wrote: Hello, Thanks for all the help this list is providing, Here is today's problem: #!/usr/bin/perl $test = dave David Davy; $i=0; ### Does not work want to count the number of matches... $regex= ($test=~ s/(dav)/$i++ $1/eig); print $regex $i ; ### This does work.. $regex= ($test=~ s/(dav)/$1 Smith/ig); print $regex ; __END__ It looks like $regex contains the number of matches, what I wanted to was capture the modified string Also can some provide an example of how to use the 'e' switch in a regrex, Thanks Dave __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: ftp
I've got Net::ftp on my win2k machine, and have used it many many times without issue. I recall just grabbing the Bundle::LWP ppm and it did the rest. I'm certain that this module should install into active state perl without grief. Good luck. http://aspn.activestate.com/ASPN/Products/ActivePerl/site/lib/Bundle/LWP.html ~Matt C. --- kosta gruzdnev [EMAIL PROTECTED] wrote: Thank all the perl gurus answering our naive novices' questions. ok, now the problem is: I try to install Net::FTP in WinNT. ppm says there is no such PPD file. That's ok, I don't object. As far as I can see, I cannot influence it. Or can I? Anyway, what are the ways (lazy ones :] ) to install perl packages in WinNT. Or, again, which man-page or doc should I read to learn about it? Thank you again, kosta __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Yet another @INC question...
This one has me puzzled. I installed Term::Readkey. Totally standard, all tests passed. Here's what I get when I try and run my script (OS is Solaris 8): Can't locate Term/Readkey.pm in @INC (@INC contains: /usr/local/lib/perl5/5.6.0/sun4-solaris /usr/local/lib/perl5/5.6.0 /usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .) Ok -- fair enough. But when I go to the following directory (copied directly from the @INC array paths above): /usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris Sure enough, it installed there: /usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris/Term The Term directory is 100% there, and moreover the Readkey.pm module is inside that! Any ideas? perl -I does not work either. I'm stumped. And all I wanted to do was suppress password echo on STDIN! Versions: perl 5.6 Term::Readkey 2.14 Thanks, Matt C. __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: Using SSL and Perl to Gather Process Information
You may want to check this out: http://search.cpan.org/doc/BTROTT/Net-SSH-Perl-1.13/lib/Net/SSH/Perl.pm I bet this will get you where you want to go. ~Matt C. --- Ken Hammer [EMAIL PROTECTED] wrote: I need to write a perl script that will gather system information from remote machines. I must communicate to the remote machines using SSL. I'm thinking I can use the Socket method to accomplish this, but I have had little luck in figuring it out. Can anyone point me in the right direction? Thank you. -- Ken Hammer Information Technology Central Services University Of Michigan [EMAIL PROTECTED] __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: beginner here - with basic cgi trouble
Type which perl at the command line to see the path to your perl interpreter. --- Brett W. McCoy [EMAIL PROTECTED] wrote: On Thu, 10 May 2001, lemoninsz wrote: hi,i have the same problem,when i do ./emailupload.cgi,error like this: bash: ./emailupload.cgi: No such file or directory the other cgi scripts work well,but emailupload.cgi.the following is the emailupload.cgi: #!/usr/bin/perl ^ Is this the correct path to Perl? -- Brett http://www.chapelperilous.net/btfwk/ Lewis's Law of Travel: The first piece of luggage out of the chute doesn't belong to anyone, ever. __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: How to recursively tar ?
Why isn't the standard tar utility working for you? Try and avoid making things more complicated than they need to be. Once I spend 45 minutes making a perl script only to realize that I could get the same results with a one-liner and pipes on the command line! ~Matt --- [EMAIL PROTECTED] wrote: All, What is the best way to create a tar archive using Archive module for a large directory structure with some 5000 files ? Currently I am using UNIX tar for this. Do I read all the files and directory and then use Archive module to tar them? If anybody can give me an idea for the syntax, I would appreicate. Thx Kailash Note : I am a beginner. __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: calling a Java class and also its memeber functions from Perl.
I'm quickly getting out of my league here, but it sounds like you may want to consider using SOAP::Lite for a remote call like that. I've never used this module, but have perused the docs and it looks very very cool and easy to use. --- Srinivas Samavedam [EMAIL PROTECTED] wrote: Hi, My perl code has to execute a couple of methods provided by a Java Class (Object). Can I do that? if so, how?. I am runing PREL 5.0 on Unix and Java 1.1.3 thanks in advance, srinivas __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Re: FTP package
I may be wrong, but it looks like machine 2 doesn't have the Net::FTP module installed. Try this to see if it is: perldoc Net::Ftp If it's installed, you'll see some text pop up straight away. As for machine one, I'm not too sure. I'm sure someone on the list can help! ~Matt C. --- [EMAIL PROTECTED] wrote: I've written a script to FTP files. I've included the Net::FTP package but when I run the script in 2 different machines, I get these 2 error messages: machine 1 Can't locate object method new via package Net::FTP::A at /usr/local/lib/per l5/5.00503/Net/FTP/A.pm line 18. machine2 Can't locate Net/FTP.pm in @INC (@INC contains: /usr/local/lib/perl5.004-04/sun4 -solaris/5.00404 /usr/local/lib/perl5.004-04 /usr/local/lib/perl5.004-04/site_pe rl/sun4-solaris /usr/local/lib/perl5.004-04/site_perl /usr/local/lib/perl5 .) at unix_ftp.pl line 3. Any ideas? __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/