Checking the Machine's Operating System
Hi Folks, I have a requirement from the clinet where in i have to take control of the machines (either by telnet,SSH). My first point to be addressed is how can i take a remote machine TELNET through perl script and also once i take the same i have to check the type of operating system and then find the size of the disks partitioned. Waiting for your help at the earliest Thanks in Advance Mazhar
Re: Checking the Machine's Operating System
On Mon, 2005-11-21 at 14:16 +0530, Mazhar wrote: Hi Folks, Hello I have a requirement from the clinet where in i have to take control of the machines (either by telnet,SSH). My first point to be addressed is how can i take a remote machine TELNET through perl script and also once i take the same i have to check the type of operating system and then find the size of the disks partitioned. Waiting for your help at the earliest I would look at Network Programming with Perl by Lincoln D. Stein. I might also have a look at CPAN (search.cpan.org) and search for telnet and or socket. Dan. Thanks in Advance Mazhar -- Daniel Klose PhD Student - Taylor Group Mathematical Biology National Institute for Medical Research The Ridgeway Mill Hill London NW7 1AA -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Checking the Machine's Operating System
Mazhar am Montag, 21. November 2005 09.46: Hi Folks, I have a requirement from the clinet where in i have to take control of the machines (either by telnet,SSH). My first point to be addressed is how can i take a remote machine TELNET through perl script and also once i take the same i have to check the type of operating system and then find the size of the disks partitioned. Waiting for your help at the earliest Thanks in Advance Mazhar Just one thing: Don't use telnet unless absolutely necessary. It's unsecure since all data is transferred in plain text. Even if you don't login as root (or su to root after login): Don't use it. joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ?php???
JupiterHost.Net: PHP has very few templating systems and they just kill php's biggest advantage [...] There are plenty of PHP templating systems, and coding PHP gets a lot more pleasant with a good template system. I think what he meant was, most PHP template systems are simply drop in php scripts that are normal PHP that gets done (IE include()ed) as part of the page. I was thinking WASP, or Smarty, or some in PEAR. http://wasp.sourceforge.net/ http://smarty.php.net/ http://pear.php.net/search.php?q=template Oh gotcha :) Sure PHP has API's to template systms done in other languages and probably some doenn all in PHP, Perl has those too, but using them doesn't destroy the entire reason you'd want to use it in the first place. See? Very dumb PHP is, use it not. I consider this strange reasoning. Templates are about effectivity. When it is effective to do what you need to do in little new code, go for templates. Nothing needs to be destroyed in that process. If you did use a real templating system with PHP thats when you just kill php's biggest advantage because now there's no need for its embedded in HTML funtionality, bottom line: PHP blows :) Yes, there are more ways to separate application logic and content from its presentation. Right by killing the biggest feature it has :) What is killing what, in your point of view? Those templates generate both HTML and PHP, like code that gets some fresh data from some database. Templates are used for part of the system. Another advantage of perl which was not pointed in that web page is that perl has perldoc The PHP documentation at http://www.php.net/manual/en/ is very practical. What if you are coding on a machine without an internet connection? Downloadable in many formats and languages. http://www.php.net/download-docs.php But what if you are coding on a machine without an internet connection :) ? Where has the difference with perldoc gone? A default PHP installation includes the documentation. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Execute newgrp system command
Hi, I want to login into a new group using 'newgrp' UNIX command.Every newgrp command invokes a new shell. But when I am trying to execute this system command from a perl script the script is terminating and returning the prompt of the new shell . Can anyone suggest on what can be done to change into a new group from within perl script? Regards, Suvajit -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Modifying column values of file records and appending to end of file.
Hi, I'm new to PERL and would like to seek help for the task mentioned below: I'm attempting to read the contents of a file containing rows with the format shown below: version|exchange|area|date|time|callmod|callid|callno1|callno2|part2|start_date|start_time|spare|dur|flag_ini|indicator|length|ni|calling_nai|screening|address_i|num_plan_ind|publicservice_user|spare1|spare2|calling_no|line_no|spare3|spare4|called_nai|called_num_plan_ind|spare5|called_num|spare6|di_nai|di_num_plan_ind|spare7|dest_num|dest_num_type|spare8|doc|dccc_type|spare9|dt_update|spare10|subs_type|cug_code|spare11|teleservices|spare12|channel_isdn|calling_terminal|pulses|in_port|out_port|in_pop|out_pop|spare13|out_mod|spare14|link2bb_type|out_cic|in_cic|anomaly_code|anomaly_ind|spare15|spare16|location|cause_value|spare17|final_status|ingress_ip|egress_ip|inter_dur|bid_time|term_call_setup_delay|del_call_setup_delay|term_ccd|int_call_clear_delay|trans_delay|inter_jitter|send_packets|send_octets|rec_packets|rec_octets|lost_packets|lost_packets_out|packet_period|code_alg|spare20|silence_suppr|spare21|coi|spare22| E144100TT|006030766|0521|051018|191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| I'm interested in modifying the values at the 3rd and 26th column of 1 particular row in this file and duplicating that row values to populate it to 4000 rows. There are 2123 rows in the this file currently. Below is the script which I've written in order to modify the values at the column mentioned. However, I'm not sure how I could rewrite the newly modified column values of that particular row back into the file - I want to use the particular row which had its columns modified to be duplicated and appended to the end of the current file for a specific number of time (adding more rows with the duplicated rows). version|exchange|area|date|time|callmod|callid|callno1|callno2|part2|start_date|start_time|spare|dur|flag_ini|indicator|length|ni|calling_nai|screening|address_i|num_plan_ind|publicservice_user|spare1|spare2|calling_no|line_no|spare3|spare4|called_nai|called_num_plan_ind|spare5|called_num|spare6|di_nai|di_num_plan_ind|spare7|dest_num|dest_num_type|spare8|doc|dccc_type|spare9|dt_update|spare10|subs_type|cug_code|spare11|teleservices|spare12|channel_isdn|calling_terminal|pulses|in_port|out_port|in_pop|out_pop|spare13|out_mod|spare14|link2bb_type|out_cic|in_cic|anomaly_code|anomaly_ind|spare15|spare16|location|cause_value|spare17|final_status|ingress_ip|egress_ip|inter_dur|bid_time|term_call_setup_delay|del_call_setup_delay|term_ccd|int_call_clear_delay|trans_delay|inter_jitter|send_packets|send_octets|rec_packets|rec_octets|lost_packets|lost_packets_out|packet_period|code_alg|spare20|silence_suppr|spare21|coi|spare22| E144100TT|006030766|AAA||191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| E144100TT|006030766|AAA||191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| Could anyone help me out? Thanks Danny ##open file for reading open(INPUTFILE, $inputFile) || die Cannot open $inputFile \n; @fileRecs = INPUTFILE; $totalRecs = scalar(@fileRecs)-1; print Total records in $inputFile is $totalRecs \n; ##open file for writting output open(OUTFILE, $inputFile.tmp) || die Cannot open $inputFile.tmp \n; $secondRow = $fileRecs[2]; print BEGINNING -- secondRow = $secondRow \n; @secondRowRec = split(|, $secondRow); $secondRowRec[2]=; $secondRowRec[3]=B; print \$secondRowRec[2] = $secondRowRec[2] and \$secondRowRec[3]=$secondRowRec[3] \n; print \$secondRow is now $secondRow \n; $diffOfNewRec = 4000 - $totalRecs; print Need to produce additional $diffOfNewRec \n; #making a backup copy `cp $inputFile $inputFile.tmp`; ## I'm need help here !! Not sure how I could re-join the elements modified back into the array containing that particular row and append it to the end of the file ## print OUTFILE for ($i=0;$i$diffOfNewRec; $i++){ print OUTFILE $secondRow\n; } close OUTFILE; - Yahoo! FareChase - Search multiple travel sites in one click.
Anyone know how to conver perl to exe
Hi All Anyone know how to convert perl to an exe. I wanted to know of any utility available in perl. Thanks Anish
Re: how to interupt a running program
S, karthik (IE03x) wrote: I need to control a perl program from another perl program. See: perldoc perlipc (search for Signals) perldoc perlvar (search for %SIG) perldoc -f kill Also: perldoc -f fork perldoc -f wait The kill function sends a signal to another process, it does not necessarily kill it. How the process responds to the signal is its business. The only except is the KILL signal (signal number 9) which always kills the process. Unfortunately the function to send signals to other processes is called kill, which leads to lots of confusion. -- Just my 0.0002 million dollars worth, --- Shawn Probability is now one. Any problems that are left are your own. SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Execute newgrp system command
Suvajit Sengupta wrote: Hi, I want to login into a new group using 'newgrp' UNIX command.Every newgrp command invokes a new shell. But when I am trying to execute this system command from a perl script the script is terminating and returning the prompt of the new shell . Can anyone suggest on what can be done to change into a new group from within perl script? Short answer: You can't. Long answer: The newgrp command will always run a new shell regardless if it succeeds or fails. What you can do instead is set the effective group id for the script. 1. Change the script's group to the group you want it to work under (see `man chgrp`). 2. Change the script's set group id on execution flag (see `chmod`). The script will now run under the new group. See `perldoc perlvar` and search for $) and $(. -- Just my 0.0002 million dollars worth, --- Shawn Probability is now one. Any problems that are left are your own. SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Anyone know how to conver perl to exe
Hi, Use perlapp from Perl Developer Kit (from www.activestate.com) Or use PAR (search for it with search.cpan.org) Or use perl2exe (from Indigo perl site). Teddy - Original Message - From: Anish Kumar K. [EMAIL PROTECTED] To: beginners@perl.org Sent: Monday, November 21, 2005 3:33 PM Subject: Anyone know how to conver perl to exe Hi All Anyone know how to convert perl to an exe. I wanted to know of any utility available in perl. Thanks Anish -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Modifying column values of file records and appending to end of file.
Danny Fang wrote: However, I'm not sure how I could rewrite the newly modified column values of that particular row back into the file - I want to use the particular row which had its columns modified to be duplicated and appended to the end of the current file for a specific number of time (adding more rows with the duplicated rows). It is considered bad form to write back into a text file since a change of length of one byte in a record could screw-up the rest of the file. #!/usr/bin/perl use strict; use warnings; use diagnostics; ##open file for reading open(INPUTFILE, $inputFile) || die Cannot open $inputFile \n; # Is $inputFile tainted? That is, is it hard-coded # or a user given value. To protect yourself from # malicious users, use: open INPUTFILE, $inputFile or die ...; # If you don't see why, ask yourself what if the # user gives ~/.profile as the $inputFile? # What if he gives rm -fr * |? @fileRecs = INPUTFILE; $totalRecs = scalar(@fileRecs)-1; print Total records in $inputFile is $totalRecs \n; ##open file for writting output open(OUTFILE, $inputFile.tmp) || die Cannot open $inputFile.tmp \n; $secondRow = $fileRecs[2]; print BEGINNING -- secondRow = $secondRow \n; @secondRowRec = split(|, $secondRow); $secondRowRec[2]=; $secondRowRec[3]=B; # Now put the record back together. $secondRow = join( |, @secondRowRec ); $fileRecs[2] = $secondRow; print \$secondRowRec[2] = $secondRowRec[2] and \$secondRowRec[3]=$secondRowRec[3] \n; print \$secondRow is now $secondRow \n; $diffOfNewRec = 4000 - $totalRecs; print Need to produce additional $diffOfNewRec \n; #making a backup copy `cp $inputFile $inputFile.tmp`; # Bad idea. You have just opened $inputFile.tmp for writing. Try: use File::Copy qw( copy move ); copy( $inputFile, $inputFile.bak ); ## I'm need help here !! Not sure how I could re-join the elements modified back into the array containing that particular row and append it to the end of the file ## print OUTFILE for ($i=0;$i$diffOfNewRec; $i++){ print OUTFILE $secondRow\n; } close OUTFILE; for my $rec ( @fileRecs ){ print OUTFILE, $rec or die cannot write to output: $!; } # To speed up processing, the computer stores # up file writes in a buffer and only # writes when it is full. The close command # will write the last little piece in the buffer # and should be tested for error. close OUTFILE or die cannot write to output: $!; # Now move the new file to the old. move( $inputFile.tmp, $inputFile ); __END__ You mentioned that you want to add more records to the end but you haven't indicated what they are. -- Just my 0.0002 million dollars worth, --- Shawn Probability is now one. Any problems that are left are your own. SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: certification in perl
karthik == karthik S [EMAIL PROTECTED] writes: karthik Could someone tell me a worthy certification in PERL (not to learn but karthik to have a recognized one)? None are recognized. If someone is trying to sell you one, it's cash for them, but nothing for you. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Modifying column values of file records and appending to end of file.
Danny Fang am Montag, 21. November 2005 13.59: Hi, Hello Danny I'm new to PERL and would like to seek help for the task mentioned below: I'm attempting to read the contents of a file containing rows with the format shown below: version|exchange|... E144100TT|006030766|0521|... I'm interested in modifying the values at the 3rd and 26th column of 1 particular row in this file and duplicating that row values to populate it to 4000 rows. There are 2123 rows in the this file currently. Below is the script which I've written in order to modify the values at the column mentioned. However, I'm not sure how I could rewrite the newly modified column values of that particular row back into the file - I want to use the particular row which had its columns modified to be duplicated and appended to the end of the current file for a specific number of time (adding more rows with the duplicated rows). version|exchange|area|... E144100TT|006030766|... E144100TT|006030766|... Could anyone help me out? Thanks Danny Don't forget to check user input to the script. ##open file for reading open(INPUTFILE, $inputFile) || die Cannot open $inputFile \n; @fileRecs = INPUTFILE; close the file here... perldoc -f close $totalRecs = scalar(@fileRecs)-1; This will return -1 if there are no lines. print Total records in $inputFile is $totalRecs \n; ##open file for writting output open(OUTFILE, $inputFile.tmp) || die Cannot open $inputFile.tmp \n; ... and reopen it in append mode instead of above. open (OUTFILE, '', $inputFile.tmp) or die Cannot open $inputFile.tmp: $! \n; (note the usage of $! to get the system error). perldoc -f open perldoc perlvar $secondRow = $fileRecs[2]; print BEGINNING -- secondRow = $secondRow \n; $secondRow (scalar) does not exist, but @secondRow (array) does. You are warned if such thins occur if you put the following lines at the beginning of every script oder module: use strict; use warnings; @secondRowRec = split(|, $secondRow); $secondRowRec[2]=; $secondRowRec[3]=B; print \$secondRowRec[2] = $secondRowRec[2] and \$secondRowRec[3]=$secondRowRec[3] \n; print \$secondRow is now $secondRow \n; $diffOfNewRec = 4000 - $totalRecs; print Need to produce additional $diffOfNewRec \n; #making a backup copy `cp $inputFile $inputFile.tmp`; You have this file already opened; and no error checking is done for the copy operation. perldoc -f system perldoc perlop (Quote and Quote-like Operators) perldoc File::Copy ## I'm need help here !! Not sure how I could re-join the elements modified back into the array containing that particular row and append it to the end of the file ## print OUTFILE for ($i=0;$i$diffOfNewRec; $i++){ print OUTFILE $secondRow\n; } You could pack the row changements and the appending to the file in a loop: for (1..$diffOfNewRec) { # change the row in some way here my $line=join '|', @secondRow; # concat values print OUTFILE $line, \n; # and append it to the file } close OUTFILE or die $!; perldoc perlsyn (loops) perldoc -f join close OUTFILE; hoping to help joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Modifying column values of file records and appending to end of file.
On 11/21/05, Danny Fang [EMAIL PROTECTED] wrote: Hi, I'm new to PERL and would like to seek help for the task mentioned below: I'm attempting to read the contents of a file containing rows with the format shown below: version|exchange|area|date|time|callmod|callid|callno1|callno2|part2|start_date|start_time|spare|dur|flag_ini|indicator|length|ni|calling_nai|screening|address_i|num_plan_ind|publicservice_user|spare1|spare2|calling_no|line_no|spare3|spare4|called_nai|called_num_plan_ind|spare5|called_num|spare6|di_nai|di_num_plan_ind|spare7|dest_num|dest_num_type|spare8|doc|dccc_type|spare9|dt_update|spare10|subs_type|cug_code|spare11|teleservices|spare12|channel_isdn|calling_terminal|pulses|in_port|out_port|in_pop|out_pop|spare13|out_mod|spare14|link2bb_type|out_cic|in_cic|anomaly_code|anomaly_ind|spare15|spare16|location|cause_value|spare17|final_status|ingress_ip|egress_ip|inter_dur|bid_time|term_call_setup_delay|del_call_setup_delay|term_ccd|int_call_clear_delay|trans_delay|inter_jitter|send_packets|send_octets|rec_packets|rec_octets|lost_packets|lost_packets_out|packet_period|code_alg|spare20|silence_suppr|spare21|coi|spare22| E144100TT|006030766|0521|051018|191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| I'm interested in modifying the values at the 3rd and 26th column of 1 particular row in this file and duplicating that row values to populate it to 4000 rows. There are 2123 rows in the this file currently. Below is the script which I've written in order to modify the values at the column mentioned. However, I'm not sure how I could rewrite the newly modified column values of that particular row back into the file - I want to use the particular row which had its columns modified to be duplicated and appended to the end of the current file for a specific number of time (adding more rows with the duplicated rows). version|exchange|area|date|time|callmod|callid|callno1|callno2|part2|start_date|start_time|spare|dur|flag_ini|indicator|length|ni|calling_nai|screening|address_i|num_plan_ind|publicservice_user|spare1|spare2|calling_no|line_no|spare3|spare4|called_nai|called_num_plan_ind|spare5|called_num|spare6|di_nai|di_num_plan_ind|spare7|dest_num|dest_num_type|spare8|doc|dccc_type|spare9|dt_update|spare10|subs_type|cug_code|spare11|teleservices|spare12|channel_isdn|calling_terminal|pulses|in_port|out_port|in_pop|out_pop|spare13|out_mod|spare14|link2bb_type|out_cic|in_cic|anomaly_code|anomaly_ind|spare15|spare16|location|cause_value|spare17|final_status|ingress_ip|egress_ip|inter_dur|bid_time|term_call_setup_delay|del_call_setup_delay|term_ccd|int_call_clear_delay|trans_delay|inter_jitter|send_packets|send_octets|rec_packets|rec_octets|lost_packets|lost_packets_out|packet_period|code_alg|spare20|silence_suppr|spare21|coi|spare22| E144100TT|006030766|AAA||191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| E144100TT|006030766|AAA||191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| Could anyone help me out? Thanks Danny ##open file for reading open(INPUTFILE, $inputFile) || die Cannot open $inputFile \n; @fileRecs = INPUTFILE; $totalRecs = scalar(@fileRecs)-1; print Total records in $inputFile is $totalRecs \n; ##open file for writting output I'm not sure where you're headed here: the number of lines in the file is @fileRecs, not @fileRecs-1. open(OUTFILE, $inputFile.tmp) || die Cannot open $inputFile.tmp \n; $secondRow = $fileRecs[2]; print BEGINNING -- secondRow = $secondRow \n; This is actually the thrid row. Perl indexes arrays beginning with zero (although it keep couunt of the number of elements counting from 1). @secondRowRec = split(|, $secondRow); $secondRowRec[2]=; $secondRowRec[3]=B; print \$secondRowRec[2] = $secondRowRec[2] and \$secondRowRec[3]=$secondRowRec[3] \n; print \$secondRow is now $secondRow \n; $diffOfNewRec = 4000 - $totalRecs; print Need to produce additional $diffOfNewRec \n; #making a backup copy `cp $inputFile $inputFile.tmp`; 1) Dont' use backticks unless you're capturing output; use system(). 2) You already created
Re: Execute newgrp system command
On 11/21/05, Shawn Corey [EMAIL PROTECTED] wrote: Suvajit Sengupta wrote: Hi, I want to login into a new group using 'newgrp' UNIX command.Every newgrp command invokes a new shell. But when I am trying to execute this system command from a perl script the script is terminating and returning the prompt of the new shell . Can anyone suggest on what can be done to change into a new group from within perl script? Short answer: You can't. Long answer: The newgrp command will always run a new shell regardless if it succeeds or fails. What you can do instead is set the effective group id for the script. 1. Change the script's group to the group you want it to work under (see `man chgrp`). 2. Change the script's set group id on execution flag (see `chmod`). The script will now run under the new group. See `perldoc perlvar` and search for $) and $(. See also Posix::setgid(). --j -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
rearranging a string
In my situation I have a string like so: my $string = '20050516'; and I want to rearrange it to look like: 05162005, so I tried: my $newstring = substr($string,0,8).substr($string,0,4).substr($string,8,0); But my problem is: it's leaving 2005 in the beginning of the string to look like 200505162005 when all I need is 05162005 Any ideas? thx Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: rearranging a string
On Nov 21, [EMAIL PROTECTED] said: In my situation I have a string like so: my $string = '20050516'; and I want to rearrange it to look like: 05162005, so I tried: my $newstring = substr($string,0,8).substr($string,0,4).substr($string,8,0); That should be: substr($string, 4, 2) . substr($string, 6, 2) . substr($string, 0, 4) The first argument is the OFFSET, and the second argument is the LENGTH. -- Jeff japhy Pinyan% How can we ever be the sold short or RPI Acacia Brother #734% the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: rearranging a string
Roberto Etcheverry [EMAIL PROTECTED] To r[EMAIL PROTECTED] cc 11/21/2005 02:19 PMSubject Re: rearranging a string [EMAIL PROTECTED] wrote: In my situation I have a string like so: my $string = '20050516'; and I want to rearrange it to look like: 05162005, so I tried: my $newstring = substr($string,0,8).substr($string,0,4).substr($string,8,0); But my problem is: it's leaving 2005 in the beginning of the string to look like 200505162005 when all I need is 05162005 Any ideas? my $newstring = substr($string,4,4).substr($string,0,4); Should do the trick... thx Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 * ** thanks Roberto! that did work. : ) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: rearranging a string
[EMAIL PROTECTED] h.com To 11/21/2005 02:33 beginners@perl.org PM cc Subject Re: rearranging a string Roberto Etcheverry [EMAIL PROTECTED] To r[EMAIL PROTECTED] cc 11/21/2005 02:19 PMSubject Re: rearranging a string [EMAIL PROTECTED] wrote: In my situation I have a string like so: my $string = '20050516'; and I want to rearrange it to look like: 05162005, so I tried: my $newstring = substr($string,0,8).substr($string,0,4).substr($string,8,0); But my problem is: it's leaving 2005 in the beginning of the string to look like 200505162005 when all I need is 05162005 Any ideas? my $newstring = substr($string,4,4).substr($string,0,4); Should do the trick... thx Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 * ** thanks Roberto! that did work. : ) * * However, is one way more efficient that the other. To me Roberto's way seems easier to read compared to Jeff's: substr($string, 4, 2) . substr($string, 6, 2) . substr($string, 0, 4) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Perl + OpenSSL
Can anyone shed some light on why this doesn't work? $certificate = /some/where/file.pem; $encoded = ' . sha1($_) . '; $signed = system(`openssl rsautl -certin $certificate -encrypt -in $encoded`); $signed doesn't end up as a certificate signed value, it ends up as this number 65280. $encoded is a sha1 encoded value, that part works. Everything workd except the system call to use Openssl's rsautl to sign the value of $signed. Paul Fontenot WFS - CAST Operations Email: [EMAIL PROTECTED] Phone: (480) 437-7795 This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. smime.p7s Description: S/MIME cryptographic signature
Re: rearranging a string
On 11/21/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: In my situation I have a string like so: my $string = '20050516'; and I want to rearrange it to look like: 05162005, so I tried: my $newstring = substr($string,0,8).substr($string,0,4).substr($string,8,0); But my problem is: it's leaving 2005 in the beginning of the string to look like 200505162005 when all I need is 05162005 Any ideas? my $newstring = substr($string,4,4).substr($string,0,4); Should do the trick... However, is one way more efficient that the other. To me Roberto's way seems easier to read compared to Jeff's: substr($string, 4, 2) . substr($string, 6, 2) . substr($string, 0, 4) It all depends on what you want. Jeff very nicely replicated what you were trying to do, that is, separate out the year, month, and day, and rearrange them to your liking. Roberto, on the other hand, gave you code to match your end result, not your process. Roberto's is more efficient--there's one less substring function on each pass, which may or may not make a difference if you're doing thousands of passes. Jeff's on the other hand, more closely mirrors what you were trying to do yourself. Obvously at some point you though it was important to handle the three pieces of the date separately, and Jeff's code is more flexible. Which makes most sense for your current application only you know. If lots of dates are in your future--and they probably are; dates are a common problem--what you probably really want to do is take a look at Date::Calc, Date::Manip, Date::Parse, etc. HTH, -- jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
Find Error Message
Hello I am working on a perl script and the 1st step is to get a list of all the files on the C drive. I am getting an error message - Can't stat c:*.*: No such file or directory Here is my perl script: use strict; use warnings; use File::Find; $| = 1; #Autoflush STDOUT #finddepth comes from File::Find #finddepth searches from the bottom of the tree up #finddepth(\BadNames,c:\\Directory); find(\BadNames,c:\\*.*); sub BadNames { print $_; print \n; } What should the find statement look like? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Find Error Message
I think it will work if you just leave out the *.* it will work. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, November 21, 2005 12:14 PM To: beginners@perl.org Subject: Find Error Message Hello I am working on a perl script and the 1st step is to get a list of all the files on the C drive. I am getting an error message - Can't stat c:*.*: No such file or directory Here is my perl script: use strict; use warnings; use File::Find; $| = 1; #Autoflush STDOUT #finddepth comes from File::Find #finddepth searches from the bottom of the tree up #finddepth(\BadNames,c:\\Directory); find(\BadNames,c:\\*.*); sub BadNames { print $_; print \n; } What should the find statement look like? -- 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 + OpenSSL
[EMAIL PROTECTED] wrote: Can anyone shed some light on why this doesn't work? $certificate = /some/where/file.pem; $encoded = ' . sha1($_) . '; $signed = system(`openssl rsautl -certin $certificate -encrypt -in $encoded`); $signed doesn't end up as a certificate signed value, it ends up as this number 65280. See: perldoc -q Why can't I get the output of a command with system()? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Find Error Message
[EMAIL PROTECTED] wrote: I am getting an error message - Can't stat c:*.*: No such file or directory find(\BadNames,c:\\*.*); What should the find statement look like? The argument should be a directory name (or multiple directories), not a glob pattern. So use C:\\, or c:/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
File Finding
Hello I got the file command to work but it is not as complete as I would have hoped for. I was hoping to get the file size and directory of the file so I could put them into arrays. Is there a way I can do it with the find command? Andrew -- 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 + OpenSSL
Well, that explained that. Is there a way to do this then? Or am I barking up the wrong tree? -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Monday, November 21, 2005 2:06 PM To: Fontenot, Ward P. Cc: beginners@perl.org Subject: Re: Perl + OpenSSL [EMAIL PROTECTED] wrote: Can anyone shed some light on why this doesn't work? $certificate = /some/where/file.pem; $encoded = ' . sha1($_) . '; $signed = system(`openssl rsautl -certin $certificate -encrypt -in $encoded`); $signed doesn't end up as a certificate signed value, it ends up as this number 65280. See: perldoc -q Why can't I get the output of a command with system()? smime.p7s Description: S/MIME cryptographic signature
Re: File Finding
Hello I got the file command to work but it is not as complete as I would have hoped for. I was hoping to get the file size and directory of the file so I could put them into arrays. Is there a way I can do it with the find command? Andrew Yes, File::Find will provide the directory. For file size, see http://perldoc.perl.org/functions/-X.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
about deleting subroutine
hi,lists, I have seen this thread on perlmonk,and it make me confused too.Can anyone here explain that?Thanks. Quote: --- Basically, deleting subroutines from a symbol table seems a bit buggy, but I don't know if this behavior is documented or not. #!/usr/bin/perl -l sub this { 'this' } print this; undef main::this; # undefine the code slot print main-can('this') ? 'main-can(this)' : '! main-can(this)'; eval {print this}; print $@; undef *main::this; # undefine the entire glob print main-can('this') ? 'main-can(this)' : '! main-can(this)'; __END__ # result this main-can(this) Undefined subroutine main::this called at sub.pl line 7. ! main-can(this) The first time I try to remove the subroutine via undef it still leaves a CODE slot in the symbol table's *this glob. I can't just use delete because it's not an array or a hash (it fails if you try). This is bad in procedural code but it's awful in OO code because $object-can('this') will succeed even if the method has been deleted. This leaves me with having to undefine the entire glob but that's a horrible solution because the other slots in the glob, if any, are blown away. Is this a known/documented bug/feature in Perl? Is there a workaround? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Modifying column values of file records and appending to end of file.
Danny Fang wrote: Hi, Hello, I'm new to PERL and would like to seek help for the task mentioned below: I'm attempting to read the contents of a file containing rows with the format shown below: version|exchange|area|date|time|callmod|callid|callno1|callno2|part2|start_date|start_time|spare|dur|flag_ini|indicator|length|ni|calling_nai|screening|address_i|num_plan_ind|publicservice_user|spare1|spare2|calling_no|line_no|spare3|spare4|called_nai|called_num_plan_ind|spare5|called_num|spare6|di_nai|di_num_plan_ind|spare7|dest_num|dest_num_type|spare8|doc|dccc_type|spare9|dt_update|spare10|subs_type|cug_code|spare11|teleservices|spare12|channel_isdn|calling_terminal|pulses|in_port|out_port|in_pop|out_pop|spare13|out_mod|spare14|link2bb_type|out_cic|in_cic|anomaly_code|anomaly_ind|spare15|spare16|location|cause_value|spare17|final_status|ingress_ip|egress_ip|inter_dur|bid_time|term_call_setup_delay|del_call_setup_delay|term_ccd|int_call_clear_delay|trans_delay|inter_jitter|send_packets|send_octets|rec_packets|rec_octets|lost_packets|lost_packets_out|packet_period|code_alg|spare20|silence_suppr|spare21|coi|spare22| E144100TT|006030766|0521|051018|191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| I'm interested in modifying the values at the 3rd and 26th column of 1 particular row in this file and duplicating that row values to populate it to 4000 rows. There are 2123 rows in the this file currently. Below is the script which I've written in order to modify the values at the column mentioned. However, I'm not sure how I could rewrite the newly modified column values of that particular row back into the file - I want to use the particular row which had its columns modified to be duplicated and appended to the end of the current file for a specific number of time (adding more rows with the duplicated rows). version|exchange|area|date|time|callmod|callid|callno1|callno2|part2|start_date|start_time|spare|dur|flag_ini|indicator|length|ni|calling_nai|screening|address_i|num_plan_ind|publicservice_user|spare1|spare2|calling_no|line_no|spare3|spare4|called_nai|called_num_plan_ind|spare5|called_num|spare6|di_nai|di_num_plan_ind|spare7|dest_num|dest_num_type|spare8|doc|dccc_type|spare9|dt_update|spare10|subs_type|cug_code|spare11|teleservices|spare12|channel_isdn|calling_terminal|pulses|in_port|out_port|in_pop|out_pop|spare13|out_mod|spare14|link2bb_type|out_cic|in_cic|anomaly_code|anomaly_ind|spare15|spare16|location|cause_value|spare17|final_status|ingress_ip|egress_ip|inter_dur|bid_time|term_call_setup_delay|del_call_setup_delay|term_ccd|int_call_clear_delay|trans_delay|inter_jitter|send_packets|send_octets|rec_packets|rec_octets|lost_packets|lost_packets_out|packet_period|code_alg|spare20|silence_suppr|spare21|coi|spare22| E144100TT|006030766|AAA||191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| E144100TT|006030766|AAA||191554|2|1529238851|63271|0|0|051018|184414|0|965|0|0|171|1|3|1|0|1|2|0|0|882030|255|0|0|3|1|0|052539028|0|3|1|0|052539028|1|0|1|0|0|0|0|SNO|0|0|0|0|0|000521882030|1|24086|27368|0|0|0|0|0|0|2|2|0|0|0|0|0|16|0|1|85.38.245.146|83.175.46.150|1|1129653851|142|0|0|0|17093|140|48227|1542980|47896|1532672|258|0||13|0|0|0||| Could anyone help me out? ##open file for reading open(INPUTFILE, $inputFile) || die Cannot open $inputFile \n; You should include the $! variable in the error message so you know why the file failed to open. @fileRecs = INPUTFILE; $totalRecs = scalar(@fileRecs)-1; $totalRecs is a scalar so the expression is in scalar context and the scalar() function is redundant. You are substracting one from the number of elements in @fileRecs so if @fileRecs contains 2,123 rows $totalRecs will be 2,122. print Total records in $inputFile is $totalRecs \n; ##open file for writting output open(OUTFILE, $inputFile.tmp) || die Cannot open $inputFile.tmp \n; You should include the $! variable in the error message so you know why the file failed to open. $secondRow = $fileRecs[2]; Array indexes start at zero so that is actually the third row. print BEGINNING -- secondRow = $secondRow \n; @secondRowRec = split(|, $secondRow); The first argument to split is a regular expression and the '|' character has a special meaning in a regular expression so if you want to match a literal '|' character you have to put a backslash in front of it. The two argument form of split() will not work
RE: File Finding
Don't forget that each module has documentation that can be accessed via 'perldoc Module::Name' So try 'perldoc File::Find' (without the quotes) at the command-prompt. Hint: Check the section called The Wanted Function. For the file size, you will probably use the stat function. One way to do this is to use an array slice like so: my $dirsize = (stat $_)[7]; Hint: File::Find sets $_ to the current filename. Do a 'perldoc -f stat' to see what the other elements are that might be useful. 7 is the file size in bytes. Remember that the Wanted function (BadNames in your case) will execute for each file. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, November 21, 2005 1:38 PM To: beginners@perl.org Subject: File Finding Hello I got the file command to work but it is not as complete as I would have hoped for. I was hoping to get the file size and directory of the file so I could put them into arrays. Is there a way I can do it with the find command? Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ?php???
PHP has very few templating systems and they just kill php's biggest advantage [...] ... Oh gotcha :) Sure PHP has API's to template systms done in other languages and probably some doenn all in PHP, Perl has those too, but using them doesn't destroy the entire reason you'd want to use it in the first place. See? Very dumb PHP is, use it not. I consider this strange reasoning. Templates are about effectivity. When it is effective to do what you need to do in little new code, go for templates. Nothing needs to be destroyed in that process. Templates are good and the poitn is: PHP's main advantage is embedded PHP/HTML + using a template systems make the embedded garbage useless = PHP is useless :) If you did use a real templating system with PHP thats when you just kill php's biggest advantage because now there's no need for its embedded in HTML funtionality, bottom line: PHP blows :) Yes, there are more ways to separate application logic and content from its presentation. Right by killing the biggest feature it has :) What is killing what, in your point of view? Those templates generate both HTML and PHP, like code that gets some fresh data from some database. Templates are used for part of the system. Right, if you're using templates of some sort then dump PHP (IE get rid of all of tis really negative and many times dangerous stuff) and use *any* other langauge that can also do templates and doesn't have its negative attributes. Another advantage of perl which was not pointed in that web page is that perl has perldoc The PHP documentation at http://www.php.net/manual/en/ is very practical. What if you are coding on a machine without an internet connection? Downloadable in many formats and languages. http://www.php.net/download-docs.php But what if you are coding on a machine without an internet connection :) ? Where has the difference with perldoc gone? A default PHP installation includes the documentation. I see, so why the urls then :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: about deleting subroutine
Jennifer Garner wrote: hi,lists, Hello, I have seen this thread on perlmonk, And you thought that the people on the beginners list would be more knowledgeable than the people on perlmonks.org? and it make me confused too.Can anyone here explain that? Explain why it makes you confused? No. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: local $/ = '';
Brian Volk wrote: Hi All~ Hello, I'm trying to get my head around local $/ = ''; #enable paragraph mode. Did you read the documentation for it in perlvar.pod? perldoc perlvar Is there anything in the documentation that you don't understand? If I have a tab delimited file that looks like this: 1311001 Aed Motorsports 5373 W 86th St Indianapolis, Indiana 46268 U.S.A. 7069210 Bird Electronic 30303 Aurora Rd Solon, Ohio 44139 U.S.A. 1020700 Charis Disk Golf Ste 160-135 4000 W 106th St Carmel, Indiana 46032 U.S.A. and code that looks like this: local $/ = ''; while (OLD) { my @rows = split /\n/; print SAVESTDOUT join(\t, @rows), \n; You don't have to split() and join() the data, this would be more efficient: chomp; tr/\n/\t/; print SAVESTDOUT $_\n; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: about deleting subroutine
Jennifer Garner wrote: hi,lists, Hi Jennifer, I have seen this thread on perlmonk,and it make me confused too.Can anyone here explain that?Thanks. Quote: --- Basically, deleting subroutines from a symbol table seems a bit buggy, but I don't know if this behavior is documented or not. Bug #37128: undefing *foo{CODE} does not fully work http://rt.perl.org/rt3/Ticket/Display.html?id=37128 Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: about deleting subroutine
hi,Randys, Bug #37128: undefing *foo{CODE} does not fully work http://rt.perl.org/rt3/Ticket/Display.html?id=37128 When I try to access that url,it require me to be verified by username and passwd. So I can't access that url. On Mon, 21 Nov 2005 22:30:00 -0500, Randy W. Sims [EMAIL PROTECTED] wrote: Jennifer Garner wrote: hi,lists, Hi Jennifer, I have seen this thread on perlmonk,and it make me confused too.Can anyone here explain that?Thanks. Quote: --- Basically, deleting subroutines from a symbol table seems a bit buggy, but I don't know if this behavior is documented or not. Bug #37128: undefing *foo{CODE} does not fully work http://rt.perl.org/rt3/Ticket/Display.html?id=37128 Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: about deleting subroutine
Jennifer Garner wrote: hi,Randys, Bug #37128: undefing *foo{CODE} does not fully work http://rt.perl.org/rt3/Ticket/Display.html?id=37128 When I try to access that url,it require me to be verified by username and passwd. So I can't access that url. username: guest passwd: guest Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Execute newgrp system command
Hi, Thanks for the suggestion. There are some tasks which are directly tied to the group-id. Owing to the requirement it may happen my perl script need to switch groups to achieve a specific task. So my plan is to change to a new group with new grp command after exporting the Environment/required variables from the current shell. After the newgrp system command from a perl script could not satisfy my need I tried including the command in a separate .cshrc file and then just sourcing that file from a perl script. But this job could not again be executed from perl script . The perl script returns error telling the sourced file could not be found. Moreover changing the scripts group permission wont do hold good for my case. I am at bay now !! Regards, Suvajit Shawn Corey wrote: Suvajit Sengupta wrote: Hi, I want to login into a new group using 'newgrp' UNIX command.Every newgrp command invokes a new shell. But when I am trying to execute this system command from a perl script the script is terminating and returning the prompt of the new shell . Can anyone suggest on what can be done to change into a new group from within perl script? Short answer: You can't. Long answer: The newgrp command will always run a new shell regardless if it succeeds or fails. What you can do instead is set the effective group id for the script. 1. Change the script's group to the group you want it to work under (see `man chgrp`). 2. Change the script's set group id on execution flag (see `chmod`). The script will now run under the new group. See `perldoc perlvar` and search for $) and $(. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response