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 ?
use strict.chdir('G:\\Documents and Settings/Administrator/eworkspace/Sample');how is that so ?\\. You are using single quotes ('). Those do not interpolate variables and other suff, so a\is a\. No need to escape. Try with one backslash. Also, the whole path with slashes and backslashes could be wrong. PS: I hate backslashes in markdown.