•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 429,739 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,978 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 540 | Replies: 6
![]() |
•
•
Join Date: Jun 2008
Posts: 11
Reputation:
Rep Power: 1
Solved Threads: 0
Hi All,
I'm new here so apologies if there's something not quite done right in my first post on here.
I'm fairly new to Perl but this is the first bit I've tried to write at home on my own.
I want to have a .pl file that runs in a browser window by passing html to it then opens a .txt file and reads it's contents into a variable, that I can use else where. I started by getting it to do this but with local files on my laptop which was pretty straightforward.
The problem at the moment is that it says it can't open the file, I'm assuming because I'm not calling it properly as I have ftp access to the files, it's chmod is correct and the path and file name is correct.
Here's the code I've worked out so far by reading up tutorials on the net...
etc
What it shows is:-
A box with some text in it...
Can't spawn "cmd.exe": No such file or directory at d:\domains\jacamar.co.uk\wwwroot\cgi-bin\page_editor.pl line 15. Can't open d:\domains\jacamar.co.uk\wwwroot\cgi-bin\Text_box_content.txt for reading
I know it can't find cmd.exe as the people who host the server say it's not compatible or something... so why on earth can't if find this Text_box_content.txt???
many thanks in advance for any replies
Sarah
I'm new here so apologies if there's something not quite done right in my first post on here.
I'm fairly new to Perl but this is the first bit I've tried to write at home on my own.
I want to have a .pl file that runs in a browser window by passing html to it then opens a .txt file and reads it's contents into a variable, that I can use else where. I started by getting it to do this but with local files on my laptop which was pretty straightforward.
The problem at the moment is that it says it can't open the file, I'm assuming because I'm not calling it properly as I have ftp access to the files, it's chmod is correct and the path and file name is correct.
Here's the code I've worked out so far by reading up tutorials on the net...
#!/usr/bin/perl
use strict;
use warnings;
print "Content-type: text/html\n\n"; # must send a header first
print "<html>";
print " <head>";
print " A box with some text in it...\n<br>";
print " </head>";
print " <body>";
if ( $^O eq "MSWin32") { system "dir" or warn "Couldn't run dir $!\n" }
else { print "Not a Windows machine.\n" }
my $INPUT_FILEHANDLE = "input_filehandle"; # open a handle to input text to
my $OUTPUT_FILEHANDLE = "output_filehandle"; # open a handle to output text to
my $INPUT_FILE_NAME = 'd:\domains\jacamar.co.uk\wwwroot\cgi-bin\Text_box_content.txt';
open (INPUT_FILEHANDLE, "<$INPUT_FILE_NAME") or die "<br>Can't open $INPUT_FILE_NAME for reading \"$!\"\n"; # open input file
etc
What it shows is:-
A box with some text in it...
Can't spawn "cmd.exe": No such file or directory at d:\domains\jacamar.co.uk\wwwroot\cgi-bin\page_editor.pl line 15. Can't open d:\domains\jacamar.co.uk\wwwroot\cgi-bin\Text_box_content.txt for reading
I know it can't find cmd.exe as the people who host the server say it's not compatible or something... so why on earth can't if find this Text_box_content.txt???
many thanks in advance for any replies
Sarah
What server you are using to run your .pl file? As far as i know, diff. web servers require to keep files in diff. hierarchy of folders in server installation path. For eg.(in Apache web server) you need to keep .pl files in ../cg-bin and like wise.
May be that is the problem, im not sure. Keep your input file in directory as your source file, then try.
katharnakh.
May be that is the problem, im not sure. Keep your input file in directory as your source file, then try.
katharnakh.
Last edited by katharnakh : Jun 4th, 2008 at 12:26 am.
challenge the limits
•
•
Join Date: Jun 2008
Posts: 11
Reputation:
Rep Power: 1
Solved Threads: 0
on a windows server and both files are in the cgi-bin.
•
•
•
•
As far as i know, diff. web servers require to keep files in diff. hierarchy of folders in server installation path. For eg.(in Apache web server) you need to keep .pl files in ../cg-bin and like wise.
May be that is the problem, im not sure. Keep your input file in directory as your source file, then try.
Does it need the full path like I've given it or does it need one like this:-
http://www.jacamar.co.uk/cgi-bin/page_editor.pl
This is the file that I'm running if it's helpful to see it in action.
many thanks
![]() |
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ad server ad serving architecture backup business centro code crash css daniweb database development div doubleclick dreamweaver enterprise firefox google google checkout haskell html hyper-v internet javascript linux longhorn mail microsoft mmorpg news open perl qmail scsi server server 2008 smtp software source symantec tables upgrade vmware w3c web windows workspace wysiwyg xml
- Previous Thread: Dos prompt after exec ()
- Next Thread: Perl in real life



Linear Mode