Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confusion with paths

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I'm "requiring" a file into my Perl scripts that contain paths and other setup information. I am trying to NOT have to specify a full path so it will work as well on my Windows NT PWS as it does on the Unix server.

The "required" set up file is in my cgi-bin with other scripts in directories under it. If I require it using a path like "../setup.pl" Perl can't find the program, but if I use "cgi-bin/setup.pl" it can. I can't figure out why it works the second way and not the first since the scripts are in subdirectories! Any clues? Is there a better way of doing it short of specifying the whole path, which defeats what I am trying to do? Thanks!

Don
 
I use the documnt root variable:
[tt]
$infile = "$ENV{'DOCUMENT_ROOT'}/directory/infile.txt";
[/tt]
I don't know if it will work on NT though. Probably not :)
 
Thanks! It's worth a try, which I will do tonight. I had tried variations on a CWD script but it gives the path of where the script was located, but I couldn't figure out how to make it "back up" a directory to give the path to where the setup file is located.

Don
 
Sadly, it does not seem to work on the NT system. I've tried accessing the IIs documentation but was not able to do so.

Don
 
Relative paths should work. if I want to go from (for example) the directory test:
[tt]
root
|
|
-------------
| |
test cgi-local
[/tt]
to the directory cgi-local I would use ../cgi-local/filename.txt
 
Strangly enough, the relative path works on the Linux Web server but not on PWS on my NT system. That's what I meant when I said I needed to remove the ../ for it to work even though there are directories above the cgi-bin but then it won't work on the linux server. Having to change it each time is defeating the purpose. I can't see why it doesn't work. I think if I could get Apache working with Perl on NT, they would be closer to each other in functionality but alas, I can't seem to do it. PWS is rather limited.

Don
 
I think it should be possible to install apache and perl on NT. I have copied the instructions for doing it that are taken from the advanced user guide of the actinic gatalog (actinic.co.uk). I hope it is of some help:

How can I set up Catalog on my Laptop?
To install a standalone Catalog system (that does not require connection to the Internet) on a laptop or any PC running NT or Win'98 you will need the following components:

Program Can be downloaded from Filename
Apache Web Server apache_1_3_12_win32.exe
ActivePerl Api522e.exe (or a newer version if available)
War-FTP Daemon ward165.exe
The above file locations are correct as of July 2000.
Installing Perl
Download ActivePerl and run the Perl installer. A successful installation can be achieved by going with all the default settings in the installer.
Installing the Apache Web Server
Run the Apache installer and follow the defaults with the exception that the installation directory should be C:\Apache.
Before the web server will run you need to edit the file httpd.conf located in the c:\Apache\conf directory. Open it with Notepad and locate the line:
#ServerName new.host.name
and replace it with
ServerName localhost
This will create a web server at C:\Apache\htdocs which should now be able to start (using the 'Start Apache as console app' option on your Start Menu.) Once Apache is started, you can go to on your browser to view the encouraging message of 'It Worked! The Apache Web Server is installed on this Web Site!'
Using Explorer, create a sub-directory 'acatalog' under 'htdocs'. Create directories called 'COM' and 'Actinic' and 'Catalog' under 'htdocs'.
Now you have:

c: +
|
+-- Apache
|
+-- htdocs
|
+-- acatalog
|
+-- COM
|
+--Actinic
|
+--Catalog
Installing and Configuring FTP
Note: These instructions are for War 1.70, which is the version available from JGAA at the time of writing.
Installation is fairly straightforward. Put the file ward165.exe into a temporary directory and run it. Then run the setup.exe program that it unpacks. Accept the defaults, and run the War daemon from the 'Start' menu.
Then you need to create a user. Double click on the War logo in the System Tray (bottom right-hand corner of your screen) and it will bring up the configuration interface. Select the menu option: ‘Properties | Security | Edit User’ and then click ‘Add’ in the left panel.
Create ‘demo’ as a user. Set up a log-in password. This will need to be secure since, if your laptop is ever connected to the Internet, it could potentially open up a hole in your computer security if you have a guessable password.
Select the ‘File access’ tab and click ‘Add’ in the path part of the tab. It prompts you with 'C:\' so navigate to ‘C:\Apache’ and hit ‘OK’.
You need to set permissions explicitly - the default grey ticks don't actually work. Set permissions to ‘Read’, ‘Write’ and ‘Delete’ but not ‘Execute’. Allow ‘List’, ‘Create’ and ‘Remove’. Check ‘Root’ and ‘Home’ and ‘Recursive’ but clear ‘Deny’ and ‘Mapping’.
Now click ‘Add’ again, select ‘C:\Apache\cgi-bin’ and this time allow ‘Read’, ‘Write’ and ‘Delete’ and ‘Execute’. Do not change any of the other settings.
Start the server by clicking on the lightning bolt in the top left corner. Then minimise the War FTP interface.
 
I have both Apache and ActivePerl installed, and even tried a special build that had both Apache and Perl in it, though I am not using Apache at the moment. Apache and Perl are both easy to get working, but I can't get Perl to work in the Web browser, only from the command line. I'll look through the material you sent in detail to see if there is a clue. (I like your user name, by the way. Even here in the U.S., we know what it means.)

Don
 
Long after I had given up on finding the problem as to why paths were different between my PWS IIS and the Linux Web server, I discovered the solution. It seems that the build of Perl I was using, which was the latest but compiled into a binary of Apache, was apparently missing something that it needed to handle paths properly. Once I removed it and reinstalled the "real" ActivePerl, the paths are much closer to being the same and in many instances I can use a little "cwd" routine to make the paths more dynamic. Relative paths seem to work more consistantly too.

Still haven't gotten Perl working with Apache though. It's as though Perl doesn't exist except from the command line, but it works fine with IIS. Still need to try some more of the tips from fortytwo and others though. I'm sure it's something easy that I'm missing.

Don [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top