How to write to drive A:\ from CGI Perl

W

William Herrera

Hi!

Please show me how to write an output.txt file from CGI perl sript to
drive A or C?
I could access drive A by HTML codes, and I know how to write to a
file from CGI Perl script. However, a Perl book shown the same thing
for CGI Perl script that doesn't work.

What operating system is the script in question running upon? Can you run the
script from a command line session on the server and get it to write to the
directory or drive you want? Are there read/write restrictions on the CGI
script's disk writing privileges?

You need to post the script in question here (not just a web page location--if
the server is configured properly, most CGI scripts can only be run as CGI, not
viewed from the internet side here).
 
T

Tintin

Cle said:
Hi!

Please show me how to write an output.txt file from CGI perl sript to
drive A or C?
I could access drive A by HTML codes, and I know how to write to a
file from CGI Perl script. However, a Perl book shown the same thing
for CGI Perl script that doesn't work.

The path from my website:

http://www.mywebsite.com/cgi-bin/cgiwrap/myName/MyFile.pl

open FILE, ">C:/some/path/output.txt" or die "Can not open
C:/some/path/output.txt $!\n";

Change C: to whatever drive is appropriate.
 
A

A. Sinan Unur

(e-mail address removed) (Cle) wrote in @posting.google.com:
Hi!

Please show me how to write an output.txt file from CGI perl sript to
drive A or C?

Easy:

#! C:/Perl/bin/perl.exe -T

use strict;
use warnings;

my $fn = 'output.txt';
open(AFILE, ">", $fn) or die "Cannot open $fn: $!\n";
print AFILE 'Output';
close(AFILE) or die "Cannot close $fn: $!\n";
__END__


This will create the file output.txt on the server's A: drive provided
you remembered to put a floppy in there.
I could access drive A by HTML codes,

Interesting ...
and I know how to write to a file from CGI Perl script.

good ...
However, a Perl book shown the same thing for CGI Perl
script that doesn't work.
So?

The path from my website:

http://www.mywebsite.com/cgi-bin/cgiwrap/myName/MyFile.pl

Hmmm ... http://www.mywebsite.com/ redirects to www.cesmarketing.com and
the link above does not work. What are you trying to do?

If you are under the illusion that you can write a CGI script that can
create a file on a floppy disk in the computer of a visitor to your site,
I would ask if you should be programming CGI scripts at all.
 
J

Jay Tilton

(e-mail address removed) (Cle) wrote:

: Please show me how to write an output.txt file from CGI perl sript to
: drive A or C?

From Perl's perspective, it's just like writing any file. The only
difference is that the filename would include a fully-specced path with the
drive name.

open FOO, '>', 'A:/thefile' or die $!;

: I could access drive A by HTML codes,

Why do you believe that has anything to do with opening a file with Perl?

: and I know how to write to a file from CGI Perl script.

Then you have the Perl part of the problem under control. The way to
specify the location of the file is OS-dependent.

: However, a Perl book shown the same thing
: for CGI Perl script that doesn't work.

Saying "doesn't work" is a waste of time. Show the program, say what you
expect it to do, and say what it really does.

: The path from my website:
:
: http://www.mywebsite.com/cgi-bin/cgiwrap/myName/MyFile.pl

What does that have to do with anything?
 
J

Jürgen Exner

Cle wrote:

Maybe I don't understand your question, but it seems as if you are
contradicting yourself (see below).
Please show me how to write an output.txt file from CGI perl sript to
drive A or C?

Here you are asking how to write to a file using Perl.
I could access drive A by HTML codes,

Side note: Not that this has anything to do with Perl, but how do you do
that? I was under the impression that HTML is a Text Markup Language and I
wasn't aware that a markup language can 'access' floppy drives. Well, maybe
as a hyperlink that is pointing to another file on the floppy, but you are
talking about writing to files.
and I know how to write to a
file from CGI Perl script.

And here you are saying you know how to write to a file using Perl. So why
are you asking about how to write to a file?
However, a Perl book shown the same thing
for CGI Perl script that doesn't work.

The meaning of this sentence eludes me

jue
 
C

Cle

Hi!

Thank you all for your helps.

My codes from html file to access my drive A which is working OK:
file:///A|/

My sample in Perl script which is also working OK:
http://www.lecan.com/cgi-bin/cgiwrap/canle/hw3mcgi.pl#EST

This is output stored in Telnet server at my website directory after I
run above script, but I wanted to write below output to drive A of my
computer:

Book List Database Sample
A2 T2 P2 E2 I2 30
b bt bp be bi 15
AA TT PP EE II 20
aa tt pp ee ii 33
--------

This is what was appeared in my telnet home directory when I wrote to
C:
C:Documents and SettingsMyName.COMPNameDesktopOutputFile.txt

I am trying to test your codes.

Thank you

Cle
 
A

A. Sinan Unur

(e-mail address removed) (Cle) wrote in
Hi!

Thank you all for your helps.

Don't take this the wrong way but I am afraid you are dabbling in things
that are way above the level of your knowledge and current skills. You seem
to be confused beyond my capacity to help you.
My codes from html file to access my drive A which is working OK:
file:///A|/

So, are you saying that you have a hyperlink

<a href="file:///A|/">A: Drive</a>

on a web page you are serving? I do not know what you are trying to
accomplish, but you should go back to basics for a while to figure out why
that is nonsensical 99.9% of the time.
My sample in Perl script which is also working OK:
http://www.lecan.com/cgi-bin/cgiwrap/canle/hw3mcgi.pl#EST

I did look at that page. What I saw was scary:

<title>http://lecan.com</title><meta http-equiv=Content-Type
content=text/html;
charset=UTF-8><font size=4 face=Verdana, helvetica><h5><body
text="blue"><br>Book List Database Sample <body text="blue"><br>

If that does not look weird to you, then please go back to basics.
This is output stored in Telnet server at my website directory after I
run above script, but I wanted to write below output to drive A of my
computer:

A CGI script running on a separate computer cannot access the drives on the
computers of visitors to that site. If that does not make sense to you,
stop what you are doing and go back to basics. The script can generate
output which the visitor can decided where to save (or whether to save).
This is what was appeared in my telnet home directory when I wrote to
C:
C:Documents and SettingsMyName.COMPNameDesktopOutputFile.txt

If you need to refer to the path

C:\Documents and Settings\MyName.COMPName\Desktop\OutputFile.txt

you need to use

C:\\Documents and Settings\\MyName.COMPName\\Desktop\\OutputFile.txt

or

C:/Documents and Settings/MyName.COMPName/Desktop/OutputFile.txt
I am trying to test your codes.

Don't. Instead, go back to basics. Learn HTML first. Learn about servers a
little. Read the CGI spec etc. Then start learning Perl by getting a good
book and going at a slow and steady pace.

Sinan.
 
J

Jürgen Exner

Cle wrote:

I am guessing, but because you seem to be unable to provide a clear scenario
it is the only option.
Please feel free to jump in at any time and correct my assumptions. Maybe we
can get a clearer picture that way.

Assumption #1: you are talking about a CGI script written in Perl running on
a web server
My codes from html file to access my drive A which is working OK:
file:///A|/

Assumption #2: here you are talking about some HMTL document that is
referencing some file on the local A drive using href="file://......". It is
irrelevant if the HTML document is a local file or if it has been downloaded
from a web server.
My sample in Perl script which is also working OK:
http://www.lecan.com/cgi-bin/cgiwrap/canle/hw3mcgi.pl#EST

This is output stored in Telnet server at my website directory after I
run above script,

I am guessing that now you are not talking about a client side (in a
server-client context) file any more, but about a server side Perl CGI
script, that writes some file to the filesystem on the server.
but I wanted to write below output to drive A of my
computer:

I am guessing again, that with "my computer" you are referring to the client
computer that is connected to a web server, which in turn runs the Perl CGI
script.

Assumption #3: I am guessing that somehow you got the idea that a
server-side Perl CGI script would be able to write a file on the client
side. If this is indeed what you are looking for: forget it.

First of all it has nothing to do with Perl. In this scenario Perl is merely
the tool, that generates the HTML document, that is sent to the client by
the web server. Or are you also blaming the hammer if your pictures aren't
hanging straight?

And second: think about what you are asking. A web server being able to
write a file to your A drive or even worse C drive? Any file? ANY? Do you
really want any website overwriting your files without your consent? Just
think about what you are asking for.

Of course I may very well be wrong. You didn't give us much information to
go on, so my assumptions and guesses may very well be way off. In that case
please try to explain in clear terms what you mean. We are not mind readers
(although some people are darn good it) and cannot know what you are trying
to do without you telling us.

jue
 
C

Cle

Hi Sinan and William.

Thank you for your times.

What browser did you look at my homepage to see only my HTML codes ? I
could view its output from my windows 98 and XP by old Netscape 4.5 to
7.1 or IE 6.0. This srcipt run OK on Linux 7.1 server.

I am having a better version of this type of Perl, and will invite you
to look at it again in the near fututre, if you have time.

I could read a file in drive A of my computer from cgi-bin Telnet by
having this line in my CGI Perl script:

print "<iframe src =\"file:///A:\FileNmae.txt"></iframe>";

The reason that I like to write to drive A: or other removable drive,
from CGI as a select option: I like to keep my file private from
SVCHOST.EXE which has RPC calls to do Remote things from windows, they
did remotely turned off my microphone at audio chatroom by RPC and
network problem, among other commands from Paltak. So any hacker can
read my file from another windows OS, even if they know my password
from camera and other methods or not, someday, they might delete or
copy my file from another PC.

I am hoping that you will have time to view my other output in near
future. I am learning about server as you suggested.

Thank you

Cle



<title>http://lecan.com</title><meta http-equiv=Content-Type
content=text/html;
charset=UTF-8><font size=4 face=Verdana, helvetica><h5><body
text="blue"><br>Book List Database Sample <body text="blue"><br>

If that does not look weird to you, then please go back to basics.

Sinan.
 
J

Jürgen Exner

[Please don't top-post]
[Please don't blindly full quote]
[Please use proper quote marks; I tried to repair as much as possible]
"A. Sinan Unur" (e-mail address removed)> wrote in message
What browser did you look at my homepage to see only my HTML codes ? I
could view its output from my windows 98 and XP by old Netscape 4.5 to
7.1 or IE 6.0. This srcipt run OK on Linux 7.1 server.

Why do you think he couldn't view the page in his browser? He didn't say
that.
But when looking at the source code of that page apparently he noticed so
many defects that any sane browser should have refused to display that page.
Please (assuming that the quoted text is an actual excerpt from the HTML
document), go back to basics and learn HTML first before trying anything
else.
Just those four lines contain half a dozen mistakes.
I am having a better version of this type of Perl, and will invite you
to look at it again in the near fututre, if you have time.

You will have a better version of Perl? Really?
I could read a file in drive A of my computer from cgi-bin Telnet by
having this line in my CGI Perl script:

print "<iframe src =\"file:///A:\FileNmae.txt"></iframe>";

Who is "I"?
- I as in the user, i.e. the person in front of the computer? Well, no need
for HTML or Perl or CGI or anything. That "I" can just read any file on any
drive using Notepad or whatever editor I like.
- I as in the web browser, that is running on the users computer? Well, a
program run by a user has the same access as the user himself. A no-brainer.
- I as in a CGI script on some web server? BS, not possible. There is no way
for a web server to read anything from a clients computer (let's ignore
security bugs for the sake of this discussion).
The reason that I like to write to drive A: or other removable drive,
from CGI as a select option: I like to keep my file private from
SVCHOST.EXE which has RPC calls to do Remote things from windows, they
did remotely turned off my microphone at audio chatroom by RPC and
network problem, among other commands from Paltak.

Who is "they"? A wild guess: the admins of your organization, maybe? Then
you may want to check if what you are trying to do does not violate the
organizations policies.
So any hacker can
read my file from another windows OS, even if they know my password
from camera and other methods or not, someday, they might delete or
copy my file from another PC.

Ok, there are two answers:
- If a hacker can access your computer (remotely), then you didn't do your
homework securing your computer. Period. That is solely your own fault and
has nothing to do whatsoever with SVCHOST, or CGI, or HTML, or Perl or any
other issue mentioned in this tedious thread
- Some people may point out that part of your problem is your OS and that
other OSes have less security flaws.
I am hoping that you will have time to view my other output in near
future. I am learning about server as you suggested.

I strongly suggest you go back and take a few additional classes about the
basics of computing and how the WWW works before coming back. Maybe I am
wrong, but you seem to be missing so much very basic knowledge that it is
difficult to even guess where you got stuck. And a newsgroup about Perl is
definitely not the right place for trying to figure it out.

As far as I am concerned: I won't read you any more. Don't take it personal,
but it's just not worth my time.

jue
 
C

Cle

Cle wrote for help: How to write to drive A:\ from CGI Perl .

jue: "...BS, not possible. ".

Cle: Jue, If you can't do it as you wrote, I thank you. Period.

I will look forward to buy your best. I will introduce my best Perl
script, which is better than the one that I am posting in my website,
then you may loose at least a customer and may more online buyers like
me, because you write Perl better than many others, and you will
nerver know that someday, one person out there can do it, as replied
by:

Sinan: Easy! ! : #! C:/Perl/bin/perl.exe ....

Tintin: open FILE, ">C:/some/path/output.txt" or die "Can not open
C:/some/path/output.txt $!\n";

My computer can't reboost with a floppy disk which is fully inserted
in drive A. I think it is safe to have a disk in there so PCAnywhere
can't remotely run my computer in future. This is why I asked such
newbie question for help, if I don't want to copy output and paste it
to my computer's Notepad then "save as" a file in drice A:!

Thank again for your helps!

Cle
 
A

A. Sinan Unur

(e-mail address removed) (Cle) wrote in
I will look forward to buy your best. I will introduce my best Perl
script, which is better than the one that I am posting in my website,
then you may loose at least a customer and may more online buyers like
me, because you write Perl better than many others, and you will
nerver know that someday, one person out there can do it,

May I politely suggest you return to whereever you came from? You are not
making any sense at all. What customers are we going to lose?
as replied by:

Sinan: Easy! ! : #! C:/Perl/bin/perl.exe ....

I said no such thing. Here is an idea: If you do not have anything
meaningful to say, please do not hesitate not to say it.

This would actually be funny if you did not have:

"with experiences in HTML, CGI, and PERL"

in your resume.
(http://www.lecan.com/cgi-bin/cgiwrap/canle/message5.cgi)
 
H

henq

A. Sinan Unur said:
(e-mail address removed) (Cle) wrote in

This would actually be funny if you did not have:

"with experiences in HTML, CGI, and PERL"

in your resume.
(http://www.lecan.com/cgi-bin/cgiwrap/canle/message5.cgi)


Perhaps you want to trade Cle some perl advice in exchange for one of his 5
copyrights?:

"Holding 5 copyrights : Variable Pi formula, Multiplication & Division
Integrations, PVT Gas Process with 2 new rules in thermodynamics, Labor
Expansion in economics, Word Processor with Math & Graphics.
 
M

Matt Garrish

A. Sinan Unur said:
I said no such thing. Here is an idea: If you do not have anything
meaningful to say, please do not hesitate not to say it.

This would actually be funny if you did not have:

"with experiences in HTML, CGI, and PERL"

in your resume.


Wouldn't this qualify as an experience in Perl?

Matt
 
C

Cle

Sinan:

Cle did not have 15 years of experinces in Perl, even he had bought 5
books and online readings in Perl, with books in Linux, such
experience can recommand a book for newbie, not yet for CGI Perl:

Paul Haffman, author of Netscape 4 and Perl for Dummies, page 175:
open(IN, "D:\ORDERS\DATA\JAN97.DAT");

Cle thank you all!

Sinan in first reply for this topic, article #4:
#! C:/Perl/bin/perl.exe -T

use strict;
use warnings;

my $fn = 'output.txt';
open(AFILE, ">", $fn) or die "Cannot open $fn: $!\n";
print AFILE 'Output';
close(AFILE) or die "Cannot close $fn: $!\n";
__END__

This will create the file output.txt on the server's A: drive provided
you remembered to put a floppy in there.
----------------------------
 
A

A. Sinan Unur

(e-mail address removed) (Cle) wrote in @posting.google.com:
Sinan:

Cle did not have 15 years of experinces in Perl, even he had bought 5
books and online readings in Perl, with books in Linux, such
experience can recommand a book for newbie, not yet for CGI Perl:

perldoc -q book
Paul Haffman, author of Netscape 4 and Perl for Dummies, page 175:
open(IN, "D:\ORDERS\DATA\JAN97.DAT");

Hmmm ... that won't do what you intended althought it does explain:
This is what was appeared in my telnet home directory when I wrote to
C:
C:Documents and SettingsMyName.COMPNameDesktopOutputFile.txt

And you should always check if your call to open succeeded:

open IN, "<", "D:/ORDER/DATA/JAN97.DAT' or die "Error: $!\n";
Sinan in first reply for this topic, article #4:

Just to set the record straight: Apparently, I forgot that I typed those
characters into my first reply to you. I did not recognize this because I
was quoted with no context. Sorry.
 
T

Tad McClellan

Cle said:
Paul Haffman, author of Netscape 4 and Perl for Dummies, page 175:
open(IN, "D:\ORDERS\DATA\JAN97.DAT");


If you read a Bad Book you will see Bad Code.

There are lots of bad "Perl books" out there, be discriminating.


You should always, yes *always, and double-especially if you
are teaching, check the return value from open().

Your book has lead you astray.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top