Re: Processing files in a directory

2008-11-11 Thread Susheel Koushik
Doing what you propose is possible, but would take system resources and a
bit tedious.

Here's an alternate solution:

From what I infer, you are processing on a file and then the code decides if
its a success or a failure and your job is to remove tmp files if it fails.
Here, when the processing code is done with its job, ask it to return an
exit status (say  return1 for success and 0 for failure). Then based on this
return status, you can do your job.

If itsn't clear, get back

-susheel

On Tue, Nov 11, 2008 at 6:18 AM, satish km [EMAIL PROTECTED] wrote:

 Hi,

 My requirement is like this:

 1. There are 1000 files in a directory(DIR1)
 2. When processing is started, ex file1 wil be converted to temp_file1,
 then processed and both file1 + temp_file1 are removed from DIR1 within 2-3
 seconds.

 if any temp_file* (ex: temp_file6) is still present in DIR1 means
 processing failed.

 So I need to periodically check in if any temp_file* generated is staying
 for more than 30 seconds (which means processing failed), then I hv to move
 this temp_file* to some other folder and restart processing again of the
 remaining files.

 I am trying to achieve this using perl. Can u plz let me know how to
 achieve this.

 Thanks,
 Satish


 On Tue, Nov 11, 2008 at 5:11 AM, Susheel Koushik [EMAIL PROTECTED]wrote:

  use the PERL system command. Its a wrapper for system call on your host
 OS.

 ex: system(mv $filename $new_location/$filename);

 susheel

   On Mon, Nov 10, 2008 at 4:39 PM, Susheel Koushik [EMAIL PROTECTED]wrote:

 use the PERL system command. Its a wrapper for system call on your host
 OS.

 ex: system(rm *.tmp);

 susheel

   On Mon, Nov 10, 2008 at 3:32 AM, [EMAIL PROTECTED] 
 [EMAIL PROTECTED] wrote:

 Hi Everyone,

 I have around 2000 files in a directory. During processing of these
 files, a temp* will be created for each file and its removed after
 processing that file. If the processing is unsuccessful, temp* file
 still exists. Can u plz help me to write a script to automate this
 process using Perl ie., when a temp* file is found (which stays for
 abt 10 secs max), I hv to move that temp* file to some other folder.

 Thanks in advance,
 Satish


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/





 --
 Susheel Koushik M
 Graduate Student
 Ira A Fulton School of Engineering
 Arizona State University




 --
 Susheel Koushik M
 Graduate Student
 Ira A Fulton School of Engineering
 Arizona State University





-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University


Re: Processing files in a directory

2008-11-11 Thread Susheel Koushik
of course, there are many ways to do a job in perl. Its upto the implementer
to choose.

-Susheel

On Mon, Nov 10, 2008 at 10:40 PM, John W. Krahn [EMAIL PROTECTED] wrote:

 Susheel Koushik wrote:

 use the PERL system command. Its a wrapper for system call on your host
 OS.

 ex: system(rm *.tmp);


 Why, when you can just do:

 unlink *.tmp;



 John
 --
 Perl isn't a toolbox, but a small machine shop where you
 can special-order certain sorts of tools at low cost and
 in short order.-- Larry Wall

 --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/





-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University


Re: Processing files in a directory

2008-11-10 Thread Susheel Koushik
use the PERL system command. Its a wrapper for system call on your host OS.

ex: system(mv $filename $new_location/$filename);

susheel

On Mon, Nov 10, 2008 at 4:39 PM, Susheel Koushik [EMAIL PROTECTED] wrote:

 use the PERL system command. Its a wrapper for system call on your host OS.

 ex: system(rm *.tmp);

 susheel

   On Mon, Nov 10, 2008 at 3:32 AM, [EMAIL PROTECTED] 
 [EMAIL PROTECTED] wrote:

 Hi Everyone,

 I have around 2000 files in a directory. During processing of these
 files, a temp* will be created for each file and its removed after
 processing that file. If the processing is unsuccessful, temp* file
 still exists. Can u plz help me to write a script to automate this
 process using Perl ie., when a temp* file is found (which stays for
 abt 10 secs max), I hv to move that temp* file to some other folder.

 Thanks in advance,
 Satish


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/





 --
 Susheel Koushik M
 Graduate Student
 Ira A Fulton School of Engineering
 Arizona State University




-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University


Re: Processing files in a directory

2008-11-10 Thread Susheel Koushik
use the PERL system command. Its a wrapper for system call on your host OS.

ex: system(rm *.tmp);

susheel

On Mon, Nov 10, 2008 at 3:32 AM, [EMAIL PROTECTED] [EMAIL PROTECTED]wrote:

 Hi Everyone,

 I have around 2000 files in a directory. During processing of these
 files, a temp* will be created for each file and its removed after
 processing that file. If the processing is unsuccessful, temp* file
 still exists. Can u plz help me to write a script to automate this
 process using Perl ie., when a temp* file is found (which stays for
 abt 10 secs max), I hv to move that temp* file to some other folder.

 Thanks in advance,
 Satish


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/





-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University


Re: Help on reading esc sequence

2007-06-11 Thread Susheel Koushik

hi amrita,

use if($var1 =~ '\e') inplace of if(var1 eq '\e')



On 6/11/07, Amrita Roy [EMAIL PROTECTED] wrote:

Hello,
Actually i m running a process using perl script.so i want to do that if i
press ESC from the keyboard it will come out of the loop n comes out of the
function.I am trying to read the esc character using \ebut it is not
responding.I have even tried with hex (1B) value of esc charcter but still
it was not respoding .
Here is code snippet:

#!/C:/Perl/bin -w
 my $var1;

$var1 = STDIN;
if($var1 eq '\e')
{
  print Hello \n;
}

else
{
  print World \n;
}


--
Amrita Roy
Rebaca Technology Pvt Ltd.
Sector 5, Saltlake,
Kolkata
Email : [EMAIL PROTECTED]



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Adding a comma to format localtime

2007-04-12 Thread Susheel Koushik

use this:

$str = localtime;
@fields = split/ /,$str;
$str2 = $fields[0].,. $fields[2]. $fields[1]. $fields[4].
$fields[3];
print ($str2\n);

On 4/9/07, Gregg O'Donnell [EMAIL PROTECTED] wrote:

All,
  I use this line of code:
  my $datetime = join ' ', (split ' ', localtime)[0,2,1,4,3];

  To create this result:
  Mon 9 Apr 2007 09:15:05

  How can I add a comma to this result to get:
  Mon, 9 Apr 2007 09:15:05

  Best and thanks,
  Gregg


-
Looking for earth-friendly autos?
 Browse Top Cars by Green Rating at Yahoo! Autos' Green Center.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/