Solved

Input output to cgi scripts

Posted on 2000-03-28
7
195 Views
Last Modified: 2010-03-05
Hi, i am new to cgi programming, i have the following job to be done. I would appreciate if someone can help me.

I am developing a tool in perl for which i have to create a web interface.  User can log into the tool through netscape. Once user clicks input button a file dialog should open asking the user to choose a file as input to the tool(The input file will be in user home directory).  This input should be fed to perl scripts on the server to get output and the output file should be supplied to the user so that he can store it in his local disk. I hope i explained the problem clearly,i would appreciate if someone can help me.
0
Comment
Question by:apaazue
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:treyjeff
ID: 2665045
What is the file that the user is entering?  Also, what is the perl script doing?
0
 
LVL 16

Accepted Solution

by:
maneshr earned 300 total points
ID: 2665090
try this....

you will have to change the HTML file to point to your cgi directory and also change the location of the PERL interpreter as per your sytem.


=================input.html
<html>
<title>Accept file as input for tool</title>


<form action="/cgi-bin/upload.pl" method=post>
<B>Enter the input file </b>
<input name="input" type="file">
<P><input type=submit>
</form>
</html>

================upload.pl
#!/usr/local/bin/perl

use CGI;

$query=new CGI;

##  Read the file name that the user has entered
$DocLocation=$query->param('inp');

print "Content-type: text/html\n\n";

##  Read 1024 bytes at a time
while($bytesread=read($DocLocation,$data,1024)){
  $size+=$bytesread;  ##  Extra!! also count the size of the file
  $content.=$data;    ##  Store the ACTUAL file content
}
close($DocLocation);

##  Now that the full content of the file is...
##  ... in the content variable, you can do whatever...
##  ... manipulations you want and then just "throw" ...
##  ... the modified content back to the user!!

print "<B>$content has been uploaded</B><br>\n";
print "<B>Size = ",$size," byte(s)</B><BR>\n";
0
 

Author Comment

by:apaazue
ID: 2665094
The user enter the input file that tool requires.  It will be in the disk of the user. the tool will parse it and takes required info from it.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:apaazue
ID: 2665113
Maneshr your comment is very intersting. As i said am new to cgi please confirm if your code works in the situation which i presented in my next comment. i.e The file is located in the user machine not on the server.   It has to be transported from user machine to remote server where perl scripts are running.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2665315
definately the script will read the entire contents of the file that the user wants and send it to the server. once at the server, you can do any processing to that content and send back the processed results to the users browser or let the user save them to his PC.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2709424
apaazue,

is there anything that i missed out on? pl. let me know.
0
 

Author Comment

by:apaazue
ID: 2709557
sure/////////////////
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
syslog unix file 20 68
add a syntax to a csv file 8 98
Need perl command line program  to test if 2 string variable is of date value and compare them 13 65
Perl Untar File 1 26
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This is an introductory video for CloudBerry Managed Backup. You will learn how to sign up with the service and get started in a few minutes.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now