write mismatch

Posted on 2006-04-20
Medium Priority
Last Modified: 2013-12-25
apache runs on host A  and all the cgi code is on host A
(cgi code uses <input type=file> to get the file

when i run executethe url from host B, i give th epath of the file c:\test\test.txt of host B.
the cgi creates a file out.txt, but cgi writes this file on the server A and not on my host B from where I am running.
Question by:perlperl
  • 3
LVL 48

Accepted Solution

Tintin earned 1500 total points
ID: 16503186
Looks like you are a little unclear on CGI, HTTP and web server technologies.

<input type=file>

is not CGI code, it is HTML.

If your CGI program/script runs on host A, the only way it can write a file on Host B is by using what ever appropriate protocol you have setup between the two hosts.  This maybe ssh, ftp, NFS, SMB, HTTP or any number of other protocols.

Author Comment

ID: 16504831
yes, i am new to cgi world....
Here is what I am looking.
I have host A, where Apache runs as web server......I have my website (all cgi scripts on host A)

now if the user hits the url http://www.hostname.com/cgi-bin/test.html  , the html  has browse button which asks user the filename.
test.html then gets redirected to http://www.hostname.com/cgi-bin/process.cgi   this creates a file called out.txt, problem it is saving the file in C: of host A.
I wwant to this file on the customers local desktop C:
What settings I need to do?

Author Comment

ID: 16504859
how can my cgi running on Host A can save a copy of file i create on customers local desktop.......

Author Comment

ID: 16504870
also, in test.html, user specifies the file c:\create.txt, but my cgi is looking for this file on host A C:\create.txt instead of using customers C:\create.txt

I am a bit confused
LVL 51

Expert Comment

ID: 16512799
> I wwant to this file on the customers local desktop C:
your process.cgi has to return the file with a HTTP-header like
  Content-Type: data/unknow
which forces the browser to open the download dialog

Assuming your process.cgi is perl, then that part looks like:

  use CGI;
  my $q=new CGI;
  $text="here is your text from the file out.txt";
  print $q->header(-type=>"data");
  ptint $text;
  exit( 0 );

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

807 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