Re: File handling using CGI

2006-07-27 Thread Ken Foskey
On Wed, 2006-07-26 at 23:57 +0530, I BioKid wrote:
> One simple question -
> I need to accept a file from the user and to store it as temp1.
> then I need to give this file as an input of another program :
> I wrote a script like this, but it is not working : Help ?
> 
> #!/usr/bin/perl -w
> use CGI;
> my $q = new CGI;
> my $file = $q->param('file');
> print $q->header();
> 
> # Reading file from user and writing to another file temp1
> open (FOO, ">temp1");
> while (<$file>)
> {
> print FOO $_;
> }
> close FOO;
> 
> # internaly executing xxx program; taking temp1 as input
> `/usr/bin/xxx temp1`;
> 
> #temp.xxx is output of usr/bin/xxx
> @psa = `cat temp1.xxx`;
> 
> foreach $i(@psa)
> {
> print "$i";
> print "";
> }


I think that you may want to look up pipes.  You can pass in data to a
program, have it process it and then get the output out from that
program without using an intermediate file.

I am curious why you wrote this:

>> @psa = `cat temp1.xxx`;
>>
>>foreach $i(@psa)

When you had this a little earlier in your code.

>>open (FOO, ">temp1");
>>while (<$file>)



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: File handling using CGI

2006-07-27 Thread Charles K. Clarkson
I BioKid wrote:

: I am able to do the second part, but am not able to get
: the users file to a variable or array ?

Read the "Files and I/O" section of the "perlintro"
file in the perl documentation.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: File handling using CGI

2006-07-26 Thread I BioKid

Dear Prabu and all,

My purpose is simple,
I have a web-form, that will accept a file,
I need to use this file as an input of a program in my server,
then I need to print the out put on the web page.

I am able to do the second part, but am not able to get the users file to a
variable or array ?
I just want to know how to pass the users file to a file called temp in my
server.

I tried this many time :( - pls help
--
thanks in advance !!!


Re: File handling using CGI

2006-07-26 Thread Prabu

I BioKid wrote:

One simple question -
I need to accept a file from the user and to store it as temp1.
then I need to give this file as an input of another program :
I wrote a script like this, but it is not working : Help ?

#!/usr/bin/perl -w
use CGI;
my $q = new CGI;
my $file = $q->param('file');
print $q->header();

# Reading file from user and writing to another file temp1
open (FOO, ">temp1");
while (<$file>)
   {
   print FOO $_;
   }
close FOO;

# internaly executing xxx program; taking temp1 as input
`/usr/bin/xxx temp1`;

#temp.xxx is output of usr/bin/xxx
@psa = `cat temp1.xxx`;

foreach $i(@psa)
{
   print "$i";
   print "";
}


Can u explain whats your requirement little more clearly.

You mean reading the file name from the user and copying the file to 
temp1 and then using this temp1.


then you can use the

`cp file1 temp1`

and then to use it in another file.

If not please explain it little more :(

--
Prabu.M.A
When I was born I was so surprised
I didnt talk for a period and half
 -Gracie Allen


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




File handling using CGI

2006-07-26 Thread I BioKid

One simple question -
I need to accept a file from the user and to store it as temp1.
then I need to give this file as an input of another program :
I wrote a script like this, but it is not working : Help ?

#!/usr/bin/perl -w
use CGI;
my $q = new CGI;
my $file = $q->param('file');
print $q->header();

# Reading file from user and writing to another file temp1
open (FOO, ">temp1");
while (<$file>)
   {
   print FOO $_;
   }
close FOO;

# internaly executing xxx program; taking temp1 as input
`/usr/bin/xxx temp1`;

#temp.xxx is output of usr/bin/xxx
@psa = `cat temp1.xxx`;

foreach $i(@psa)
{
   print "$i";
   print "";
}

--
thanks in advance,
IBK