Gerard has asked for the wisdom of the Perl Monks concerning the following question:

I have written a script (comppiled to native windows executable using perl2exe) which searches the contents of a cd and returns the results in an html file. When running the script from my hard disk everything works fine, and results are returned as expected, however when it is run from the CD nothing can be found. Let me explain in a little more detail...

I have made an "pretty" interface using Macromedia Flash MX. Unfortunately Macromedia have disallowed (for security reasons) passing parameters to external programs. This makes it very difficult to run a search program for example.

I can however open up a new browser window going to any url I see fit. I execute a perl script which is a temporary webserver with a unused port number, which catches the request from the browser containing what would have been the parameters and then stops listening for connections.

The script then does the search and writes the results to a temp file in an html format. That file is then opened up in the browser for viewing.

I have spent a while toiling over this and eventually got everything working. It is not at all efficent, but it works, and for this application that is the main concern. Although I have only used relative directory names etc., once it is written to cd it no longer works.

The CD's autorun program works and starts up the flash interface, when one searches, the perl program starts ok, and seems to receive the correct parameters, but it is unable to find any matches - for things that I know are there - and work from the hard disk. The directory structure on the CD is identical to that on the hard disk. Any ideas as to why this might not be working? I can provide more specific information if required.

Regards,

Gerard
  • Comment on Search function not working from CD Rom

Replies are listed 'Best First'.
Re: Search function not working from CD Rom
by tachyon (Chancellor) on Jan 05, 2003 at 23:34 UTC

    If you run a program on your hard disk (say C:) to access a CD rom (say E:) I fail to see how you can use a relative path as you need to specify the E: - there simply is no relative path from C: to E: This being the case I suggest your exe perhaps has a hard coded CD rom drive letter in it (given it works from the HDD). You almost certainly have a path issue.

    A script can work out where it is (ie if on the CD rom what the drive letter is) by using Cwd. This should help fix your problem.

    use Cwd; my $cwd = cwd(); my ($cdrom_drive_letter) = $cwd =~ m/^(\w:)/;
    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Sorry if I did not make it clear. When on the hard disk the files are being opened from the hard disk and when the program is on the cd the files are being opened from the cd. All paths are relative apart from the 1 saying where the temp directory is. The directory structure is identical on the hard disk(well not the whole hard disk, but the relevant parts anyway) to the cd. Regards, Gerard

        It's not something like attempting to open files with write access, is it?

        --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
Re: Search function not working from CD Rom
by gjb (Vicar) on Jan 05, 2003 at 23:10 UTC

    Where's the temp file written that contains the HTML? I suppose you're not trying to write it somewhere on the CD?

    Just a thought, -gjb-

      No, in the users temp directory - absolute location got from the environment variable. Normally something like c:\windows\temp\ or whatever.
Re: Search function not working from CD Rom
by osama (Scribe) on Jan 06, 2003 at 12:33 UTC
    try making all the files in your hard disk folder "read-only", you can use subst to give it a drive letter... Then run the program from the hard disk... make sure you're not trying to write anything on the CD...