LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-16-2010, 01:30 PM   #16
New_user_perl
LQ Newbie
 
Registered: Aug 2010
Posts: 7

Original Poster
Rep: Reputation: 0

Hi,
Thank you the above posted script worked.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-16-2010, 01:32 PM   #17
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
Old 08-16-2010, 02:47 PM   #18
New_user_perl
LQ Newbie
 
Registered: Aug 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Hi,
Below is my final script that I am working on. But I am facing some problem here. The thing is at the end of the script I am invoking an application to process my image by using fits.bat -i and using fits.bat -o to capture the output but the output file which I am mentioning is getting overwrited by the files. In detail file 1 is being processed and output is going into output.txt next file2 is being processed and the output.txt gets overwrited by the file2 output and so on.... Finally the output.txt has onluy the output of the last file instead of all the files. Is there a way i can overcome this.



#!/usr/local/bin/perl

use File::Find ;

# Get the directory from the command line # or use the default directory

$search = shift || 'C:\Documents and Settings\user\Desktop\IMD025350802' ;

# Get an array of all subdirectories
find sub { push @dirs, $File::Find::name if -d }, $search ;

for $dir ( @dirs ) {
opendir $dh, $dir or do { warn "Cannot open '$dir' $!" ; next ; } ;

opendir( DIR, "$dir" ) ;
@files = grep( /\.jpg$/, readdir( DIR ) ) ;
closedir( DIR ) ;

foreach $file ( @files ) {
print "$dir/$file\n" ;

@args = ("C:\\Documents and settings\\user\\My Documents\\Downloads\\fits-0.4.2\\fits-0.4.2\\FITS.BAT", "-i", "$dir/$file","C:\\Documents and settings\\user\\My Documents\\Downloads\\fits-0.4.2\\fits-0.4.2\\FITS.BAT", "-o", "C:\\Documents and Settings\\user\\Desktop\\output\\out.txt");

system( @args ) == 0 or die "system @args failed: $?";

}
}
 
Old 08-16-2010, 03:46 PM   #19
user_28
LQ Newbie
 
Registered: Aug 2010
Posts: 27

Rep: Reputation: 0
Hi,
The problem is solved. Created a logfilename variable and passed my file variable to it.

Thanks,
 
Old 08-16-2010, 05:07 PM   #20
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
You're the same user right? I think you should mark this as solved if that's the case.
 
Old 08-17-2010, 08:20 AM   #21
user_28
LQ Newbie
 
Registered: Aug 2010
Posts: 27

Rep: Reputation: 0
Hi,
I am not the same user. It was a small confusion and was solved with the help of administrators.
 
Old 08-17-2010, 10:07 AM   #22
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

@user_28:
Quote:
Originally Posted by user_28 View Post
Hi,
The problem is solved. Created a logfilename variable and passed my file variable to it.

Thanks,
If user_28 and New_user_perl are _not_ the same user how is it possible you (user_28) decides that this thread is solved? It was started by New_user_perl.......

I have my doubts, but you seem to have convinced the moderator.
 
Old 08-18-2010, 12:02 AM   #23
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by druuna View Post
Hi,

@user_28:If user_28 and New_user_perl are _not_ the same user how is it possible you (user_28) decides that this thread is solved? It was started by New_user_perl.......

I have my doubts, but you seem to have convinced the moderator.
Not the, a moderator (or Jeremy).


I find the story not overly plausible. Two friends
using the same machine to solve the same issue?


Cheers,
Tink
 
Old 08-18-2010, 01:32 AM   #24
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Quote:
Originally Posted by Tinkster View Post
Not the, a moderator (or Jeremy).
I always thought you are The moderator

Seriously: Should this really be a moderator?
You seem to be the moderator that handled/(un)locked this and the other thread. A moderator sounds general and impersonal in this case, the moderator points to the one handling these threads.

English is not my first language so please correct me if I'm wrong.

Last edited by druuna; 08-18-2010 at 02:01 AM. Reason: Made sentence more clear.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with perl modules declaration and perl/cgi script shifter Programming 9 02-24-2010 09:09 AM
Problem Getting A Perl Script to Run kaplan71 Linux - General 8 06-20-2008 05:19 PM
cron: problem with perl script Clemente Linux - Software 4 05-10-2006 02:30 PM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 10:22 AM
Problem with a perl script Nexis Linux - Software 3 08-08-2002 08:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration