Moving, modifying files and preserving permission's
Hello, I am in the process of migrating our current working environment from Solaris to Linux. This should have been very straight forward if I had a one-to-one mapping of filesystems, but not in my situation. I am moving from a multiple 6GB filesystems to a few 20GB filesystems, which means programs (scripts, C/C++, fortran, Pascal codes, etc.) containing hard coded PATHS need to be modified and in some cases recompiled. I have been able to come up with a "not-so-clean" piece of code which unfortunately only works on non-nfs mounted filesystems (my initial plan was to mount the old filesystems on the Linux box, and then using "finddepth(\&wanted, $old_filesystem)" go down the directory tree, modifying, recompiling and performing all that needs to be done, then writing back the resulting file to the new filesystem. However, this does not work, so I am going with a 2-step approach (manually copy the files over to the linux box), then have a scaled-down program do the PATH conversion, recompilation, etc. Here is a copy of my old code: (See attached file: solaris_to_linux.pl) (See attached file: output.txt)(See attached file: output.txt) - I am still healing my wounds from my weekend failure (i.e., currently in the process of modifying the above script, to do just the PATH conversion, and hopefully the recompilation). However, answers and/or suggestions to the following question would help. Questions: 1./ How do I modify a file and preserve the original permissions (i.e., the permission of the parent file)? Currently, I am using "File::stat", with the system command as follows: my $info = stat($old_absolute_name) or die "\n\nno $old_absolute_name: $! \n\n"; my $permstrs = $info->mode; print "\n File Mode = ", $info->mode , " USer: ", $info->uid, "\n\n"; printf "\n Permission = %0.4o \n\n", $permstrs; . . $file_perm = $file_perm & ~ (04000 | 02000); return unless 114 == (getpwuid($file_uid))[3]; # for testing purposes only `chown ${file_uid}.${file_gid} \'$file_name\'; chmod $file_perm \'$file_name\'`; #'for WINDOWS-base filenames -- spaces 2./ Does anyone have anything (code, advise, pointers, etc), they would like to share? Thank you, __ William Ampeh solaris_to_linux.pl Description: Binary data output.txt Description: Binary data output.txt Description: Binary data -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
GUI-based menu-ing script for UNIX
Is there any easy to customize GUI-based menu-ing script for UNIX? I currently have a text-base menu program for gluing my applications, and I am interested in putting in revising it to a GUI-based (for a change). Currently I am looking at aumenu, which according to the documentation, was developed way back. http://members.aol.com/aumenu/index.html Thank you. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: CGI execute command via ssh
2 things could be happening: 1./ Timeout 2./size of your descriptors. That is:on a "?nix" platform type limit You see something like: william:/foobar(1)% limit cputime unlimited filesizeunlimited datasizeunlimited stacksize 10240 kbytes coredumpsize0 kbytes memoryuse unlimited vmemoryuse unlimited descriptors 1024 memorylocked4 kbytes maxproc 7168 ______ William Ampeh (x3939) Federal Reserve Board MNibble <[EMAIL PROTECTED] de>To beginners@perl.org 08/31/2005 10:09 cc AM Subject CGI execute command via ssh Aloha I',m trying to execute a command via ssh on a remote maschien via a perl-cgi script. The app i'm building does this a lot, with 99% of success. The missing 1% i'm trying to understand and after that to solve. I use backstick to run the ssh command something like: my $data = `ssh [EMAIL PROTECTED] /root/somewhere/something $args` This work fine. But the 1% is a command where up to 5 MB are in my $data. --- Only if i run it local on the 192.168.10.8. Remote i only fetch 1.6 MB. While i doesn't matter if i should get 2,3, or 5 MB. Most annoying is that the data are strings .. and the missing one are randomly placed somewhere. After a lot of wasted time with no success i kick that solution and tried to put all the data in a MySQL DB on the remote maschine ( 192.168.10.8 ) again this works better since all data get into that DB. When execute that script from the cgi script, i get an error message. While the error message was generate from within the script from the remote maschine - this error "could no happen". I couldn't get rid of that error so i again tried a different way. This time the remote scripte run as a daemon process, with no report back to the caller, just fire and forget. Again it work direkt from commandline and via commandline call over ssh and again not from within the cgi script. What did i miss? What das CGI what works so nice agains me? here the shorted scripts; CGI Script use strict; use warnings; use CGI::FormBuilder; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use constant DEBUG => 0; my $host = $ENV{'QUERY_STRING'}; die unless ($host=~/^[\w-]+$/); my $page = CGI->new; print $page->header; print $page->start_html; print `ssh [EMAIL PROTECTED] /root/nodedateien $host`; print $page->end_html; -- Remote script --- #!/usr/bin/perl use strict; use warnings; use IO::Socket; use DBI; use POSIX; my $arg = shift or die ; die "Can't fork" unless defined ( my $child = fork); exit 0 if $child; #parent dies; setsid(); open(STDIN, "/dev/null"); open(STDERR, ">&STDOUT"); chdir '/'; #change working directory umask(0); #forget file mod creation mas my $dbh = DBI->connect('dbi:mysql:database=DB;host=localhost:3306','root','pass',{RaiseError => 1, AutoCommit => 1}); my $sth = $dbh->prepare('delete from nodedateien'); $sth->execute(); $sth = $dbh->prepare('insert into nodedateien (HL_Name,LL_Name,Backup_Date) Values ( ?,?,? ) '); open(IN,"/command" |"); my ($val1,$val2,$val3); for (1 .. 12) {} while() { next if (/^\n/); next if (/return code/); if ($_=~/^BACKUP_DATE: (.+)/) { $val3 = $1} if ($_=~/^HL_NAME: (.+)/) { $val1 = $1} if ($_=~/^LL_NAME: (.+)/) { $val2 = $1; update($val1,$val2,$val3)} } sub update { my ($HL,$LL,$BD) = @_; $sth->execute($HL,$LL,$BD); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addi
Perl IMAP client for Lotus Notes
Hello All, I am looking for a way to pull mails from Lotus Notes and process them in Perl. I will be glad if anyone will be kind enough to share a code or provide me with any pointers. Thank you. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Please help
Please help me fix this. When I run it, I get the following message: Can't call method "select" on an undefined value at ./fof_imap1.pl line 12. Thank you _ Program: #!/opt/local/bin/perl use lib "/home/william/.cpan/build/Mail-IMAPClient-2.2.9/blib/lib"; use Mail::IMAPClient; $imaphost="mymailserver.co.uk"; $login="myname"; $pass="mypassword"; my $imap = Mail::IMAPClient->new( Server => $imaphost, User => $login, Password=> $pass, Uid => 1,# optional ); $imap->select("smut"); for my $h ( # grab the Subject and Date from every message in my (fictional!) smut folder; # the first argument is a reference to an array listing all messages in the folder # (which is what gets returned by the $imap->search("ALL") method when called in # scalar context) and the remaining arguments are the fields to parse out # The key is the message number, which in this case we don't care about: values %{$imap->parse_headers( scalar($imap->search("ALL")) , "Subject", "Date")} ) { # $h is the value of each element in the hash ref returned from parse_headers, # and $h is also a reference to a hash. # We'll only print the first occurance of each field because we don't expect more # than one Date: or Subject: line per message. print map { "$_:\t$h->{$_}[0]\n"} keys %$h ; } __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Help unsubscribing from list
How do I unsubscribe from the list? Thank you __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
A simple text or GUI-based menu script
Hello, I am finally done with my 508 automation project. Thanks to everyone who responded to my mail, especially Jenda Krynicky. I am finally able to take any "structured" pdf table and convert it to a "screen readable HTML" file format. The end of one project marks the beginning of another. I have two question. 1./ Where can I locate a text or GUI-based menu program in Perl to bundle together a set of scripts and program. That is, something that will allow me to create a menu based system for in-house use. For example, a user selects option 1 to backup files, option 2 to run the "create tables programs", etc. 2./ I just down loaded http://www.cpan.org/authors/id/SKUNZ/perlmenu.v4.0.tar.gz, but have been struggle to located all the modules referenced by the demo program. First it was Curses.pm and now it is CPANPLUS/Backend.pm. What is the best way to get all the dependencies of perlmenu installed automatically? Thank you. ______ William Ampeh Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: Cron Tab Implementation
I think you are experiencing some of my headaches here. Why recreate a fully functional and extensively tested utility? My solution, when pressed, simply create an input to the utility and fire up the utility. That is, if you still want to use Perl for this, simply generate your crontab file in using a Perl script, and with command ticks, file up cron from within your Perl program. Cron is cron and all it needs if a file and a kick start. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: Excel format from a PERL script
If I understand your question correctly, then all you is Spreadsheet::WriteExcel It comes with an example which is very easy to follow. I have used this quite a bit and like I said, it is very easy to follow. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: Could anyone please answer a simple PERL question.
A sure kill is to search for "perl*" and take note of the path. Then you can do one of the following: 1./ update your path variable, verify that you have really done that with the set command. OR 2./ call up the perl interpreter using the absolute path. I think he probabily have not installed Perl. ______ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Request to help beautify a Perl-based menu script
Hello, This is the current state of my text-based Perl "menu" script. It pretty much does everything I want with the exception of colors (two of my highly influential users want colors). I will therefore appreciate any help or pointers. --- Program: (See attached file: fofp_menu_gen.pl) --- Menu file: (See attached file: projection.menu) -- COMMAND: xterm -cr blue -im +ls -ms blue \ -title "P R O J E C T I O N V 1.0" \ -fn "-schumacher-clean-medium-r-normal-*-*-120-*-75-*-*-*-*" -geometry "116x72+100+10" \ -bg "#e0" -fg black -e /PROJECTS/MENU/fofp_menu_gen.pl -m 2 \ -t PROJECTION ' \ /PROJECTS/MENU/projection.menu & exit --- SAMPLE menufile * DATA PICKUP TOOLS (Projection Coordinator/RA ONLY) * SCRIPTS_DIR = /fof/proj/PRODUCTION OTHER SOURCES HISTORY/ADDYEAR/MANUAL UPDATES * Pickup DEPOSIT :: SCRIPTS_DIR->SCRIPTS/foo.sh * Pickup HISTORY (uses fofnet database):: SCRIPTS_DIR->HISTORY_PICKUP/BIN/pickup_fofhistory.sh * Pickup RUTH :: SCRIPTS_DIR->SCRIPTS/fofproj_distributor.sh 202 * Add a year of data to a database :: SCRIPTS_DIR->SCRIPTS/fofproj_distributor.sh 100 * Pickup TFIN :: SCRIPTS_DIR->SCRIPTS/fofproj_distributor.sh 203 * Update series manually :: SCRIPTS_DIR->SCRIPTS/fofproj_distributor.sh 206 SMALL Pickups COMPARE * Pickup CONSUMER CREDIT :: SCRIPTS_DIR->SCRIPTS/fofproj_small_updates.sh 1 * CURRENT fofp and CURRENT fofproj :: SCRIPTS_DIR->SCRIPTS/fofproj_compare.sh 1 * Pickup OFHEO INDEX :: SCRIPTS_DIR->SCRIPTS/fofproj_small_updates.sh 2 ? CURRENT fofproj and LAST GREENBOOK fofp :: SCRIPTS_DIR->SCRIPTS/fofproj_compare.sh _2 * Pickup MUTUAL FUND FORECAST :: SCRIPTS_DIR->SCRIPTS/fofproj_small_updates.sh 3 * CURRENT fofp and current fofnet :: SCRIPTS_DIR->SCRIPTS/fofproj_compare.sh 3 * Pickup MORTGAGES :: SCRIPTS_DIR->SCRIPTS/fofproj_small_updates.sh 4 __ William Ampeh Federal Reserve Board fofp_menu_gen.pl Description: Binary data projection.menu Description: Binary data -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: Could anyone please help with PERL file association.
Right mouse click on Start,select Explore, locate the file, Right mouse click on the file, click on Open with, select other program, then locate the Perl interpreter (something like perl???.exe). You could select always use to lock the file association. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: how do you run the debuger for perl/TK in Windows-2000
Simply wrap it around a batch file with a pause at the end. That is: @echo off path\to\my\script echo . echo . echo . - D O N E - echo . echo . pause __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Clearing up Google history
How do I clear up my "google history" (IE history can be cleared via Tools, Options). That is, from any browser, when a user enters "www.google.com", the user is presented with a dialog box, any previously entered text is stored, how do I clear or turn off the history caching feature in google? Thanks ______ William Ampeh Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: What is "Use of uninitialized JOIN" error?
Where do you populate @record? Such messages occur when populating an array with contents of a file (if the file contains a bunch of newlines). So make sure you know what the array is getting populated with by testing. Also, you want to join before printing, correct? So swap the lines (but that is not the cause of the warning). > print OUTFILE "$recordlist\n"; >$recordlist=join(",",@record); I will try to view the contents of @record with foreach my $item (@record) { print " . item: $item\n"; } __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: [The Subroutine] What is "Use of uninitialized JOIN" error?
sub data_collect {unless (open(OUTFILE,">$fourdayreport")) {die open(ERRORLOG, ">>$errorlog") && print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return "Failed";} else{ while( @record = $sth->fetchrow_array() ) { # no warnings; #INSERTED ::: #Since you are not doing anything with $recordlist, I will do one of the following: print OUTFILE join(",",@record), "\n"; #OR: for ( my $i = 0; $i < $#record; $i++) { ( $i < $#record ) ? print "$record[$i]," : print "$record[$i]\n"; } #::INSTEAD OF : my $recordlist=join(",",@record); print OUTFILE "$recordlist\n"; }return "success"; } } __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: [The Subroutine] What is "Use of uninitialized JOIN" error?
What about manually stepping through the array elements? That is: for ( my $i = 0; $i < $#record; $i++) { print "$record[$i],"; } print "$record[$#record]\n"; __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: [The Subroutine] What is "Use of uninitialized JOIN" error?
What about manually stepping through the array elements? That is: for ( my $i = 0; $i < $#record; $i++) { print "$record[$i],"; } print "$record[$#record]\n"; __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: [The Subroutine...revisited] What is "Use of uninitialized JOIN" error?
$recordlist=join(",",@record); #This statement is causing the problem Have you tried to see if there are any blank records in @record? ______ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: Perl <-> Expect
OCK 2: Username or Password Error. Use modify router to update $hostname information!!!\n\n" exit 1 } expect { timeout { puts "\n\nWarning: Process timed out -- BLOCK 2\n\n"; exit 5 } Password: { stty -echo; send "$enable_password\r" ; stty echo; incr loop_detector1} "#" { if { $TERMINAL_LENGTH < 1 } { stty -echo; send "terminal length 0\r"; stty echo; set TERMINAL_LENGTH 1 } else { while 1 { #puts "\n .. TRIAL $loop_buf_in_use \n" if { $loop_buf_in_use > 3 } { puts "\n\nBLOCK 2: ERROR from $hostname. Possibly a buffer in use. Trials = $loop_buf_in_use!!!\n\n" exit 1 } stty -echo; send "show config\r"; stty echo; incr loop_buf_in_use #expect "show config\r\n" expect { timeout { puts "\n\nWarning: Process timed out on show config -- BLOCK 2\n\n"; exit 5 } -re "(\r\n)*.*!" { incr out_buf_in_use; break } -re "\r\n(\[#\n\r]*)" { sleep 15 } eof { puts "\n\n Error from $hostname. End of file error -- blk 2. Possibly a buffer in use!!\n\n"; exit 1 } } } } if { $out_buf_in_use > 0 } { break } } -nocase error: {puts "\n\n Error from $hostname. Possibly a password error -- Blk 2. Modify rounter information\n\n"; exit 1} -nocase error {puts "\n\n Error from $hostname. Possibly a password error -- Blk 2. Modify rounter information\n\n"; exit 1} -nocase bad { puts "\n\n Error from $hostname. Possibly a password error -- Blk 2. Modify rounter information\n\n"; exit 1} "%" { puts "\n\n Error from $hostname. Possibly a password error -- Blk 2. Modify rounter information\n\n"; exit 1} ">" {stty -echo; send "enable\r"; stty echo } eof { puts "\n\n Error from $hostname. End of file error -- blk 2. Modify rounter information\n\n"; exit 1 } } } # ..This is where I am having lots of trouble . #expect -re "\r\n(.*)\r\n" ;#match output fron show config expect -re "\n(\[#\r\n]*)\r";#match output fron show config #expect -re "\r\n(\[#\n\r]*)\r\n" ;#match output fron show config #expect -re "\r\n(\[#\n\r]*)" ;#match output fron show config #expect -re "\n(\[^\r]*)\r" ;#match output fron show config log_user 1; puts "$expect_out(1,string)" ;#print expected data only to outfile #.. close session and exit ... expect { "#" { exit 0 } eof { puts "\n\n Error from $hostname. End of file error -- blk 3. Modify rounter information\n\n"; exit 1 } timeout { puts "\n\nWarning: Timed out: Last BLOCK\n\n"; exit 6 } } #... exit 1 __ William Ampeh (x3939) Federal Reserve Board "Ohad Ohad" <[EMAIL PROTECTED] To: [EMAIL PROTECTED] .com>cc: Subject: Perl <-> Expect 07/15/2004 07:36 AM
Tcl/Tk training class
Hello, Can anyone recommend a Tcl/Tk training in DC/MD/VA? I am specifically looking for a course in intermediate to advance Tcl/Tk (including namespaces, packages, and GUI appearance). Thanks. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>