Reputation: 930
I have a CGI perl script which will first chdir
to a specified location and then run a command(This command runs only in this specified directory since it uses a input file build.xml which is in this directory, if we try to run this command in any other location, it throws a error "Build failed Buildfile: build.xml does not exist!
"). If I execute this perl script in cmd, the script works fine. But does not work in a browser, it throws the same error
"Build failed Buildfile: build.xml does not exist!
" How can this happen ? Can someone help me on how to resolve this.
Here is the code
#!/usr/local/bin/perl - w
use strict;
use CGI ':standard';
print header;
print start_html("welcome");
print "<h1>welcome</h1>\n";
print_prompt();
print end_html;
sub print_prompt {
print start_form;
print "<em>welcome</em><br>";
chdir('G:\\Documents and Settings/Administrator/eworkspace/Sample');
print `ant`;
}
Using cwd I found my directory is not getting changed with chdir('G:\\Documents and Settings/Administrator/eworkspace/Sample');
how is that so ?
Upvotes: 1
Views: 1655
Reputation: 50667
chdir('G:/Documents and Settings/Administrator/eworkspace/Sample')
or die $!;
will tell you if chdir was successful. If it wasn't it might be that web server user doesn't have access to specified folder.
Upvotes: 1