Here is the example at http://www.shuffleboard.no/TestCopy.php
i am having a problem understanding the syntax.
From PHP I am able to upload a file, then create a new one and update it OK.
I then try to do a simple test which executes exec('tst.sh test.txt test1.txt') to add a line (or lines) to the newly created file.
"tst.sh" is just 2 lines
cat $1 > $2
echo "** New line added** " >> $2
Do I need this line at the beginning of my script "#!/usr/local/bin/php -q"??
Should I be executing the tst.sh from the cgi-bin directory?
If I run TestCopy.php from the cgi-bin file I get the following errors:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@shuffleboard.no and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Any help or suggestions would be helpful?
http://www.shuffleboard.no/cgi-bin/TestCopy.php or
http://www.shuffleboard.no/TestCopy.php
Code: Select all
#!/usr/local/bin/php -q
<?php
echo "Start Now<br>";
$line1 = "<?php\n";
$line2 = "This is test line created from php\n";
$line3 = "?>\n";
$file = "./Upload/test1.txt";
$handle = fopen("$file", "w");
fwrite($handle, $line1);
fwrite($handle, $line2);
fwrite($handle, $line3);
fclose($handle);
chdir ("Upload");
chmod ("test1.txt", 0777);
echo "Hello just to check that I am Here";
echo '<pre>';
$last_line = exec('tst.sh test.txt ./Upload/test1.txt', $retval);
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
//exec ("tst.sh test.txt ./Upload/test1.txt");
echo "<br><br> That was it I wonder what the result is?";
?>