Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

PHP calling Bash-script

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Yasmin Mirza

User

( 7 months ago )

 

I have real problems getting this PHP-script "search.php" that is called from a "form.htm" to work. What am I doing wrong here?

<?php
   $old_path = getcwd();
   chdir('/var/www/html/SOKHJALPMEDEL/');
   $term1 = $_POST['query1'];
   $argument1 = $_GET['$term1'];
   $term2 = $_POST['query2'];
   $argument2 = $_GET['$term2'];
   echo $nu_kor_vi1;
   $outcome = shell_exec("sokare $argument1 $argument2");
   chdir($old_path);
   echo "<pre>$outcome</pre>";
?>

The script is calling a Bash-script "sokare" that is executable systemwide and residning in "/usr/local/bin". The variables $argument1 and $argument2 are passed from the "form.htm" via $term1 = $_POST['query1']; and $term2 = $_POST['query2']; . The Bash-script looks like this. It is supposed to search any PDF-files residing in "/var/www/html/SOKHJALPMEDEL/" for pages containing both searchwords.

#!/bin/bash

pdfgrep -Hn $1 /var/www/html/SOKHJALPMEDEL/*.pdf | cut -f1,2 -d':' > /tmp/sok1.tmp
pdfgrep -Hn $2 /var/www/html/SOKHJALPMEDEL/*.pdf | cut -f1,2 -d':' > /tmp/sok2.tmp
grep -f /tmp/sok1.tmp /tmp/sok2.tmp

exit 0

I keep on getting this error in "/var/log/apache2/error.log" : PHP Notice: Undefined index: $term2 in /var/www/html/SOKHJALPMEDEL/search.php on line 7, referer: http://localhost/SOKHJALPMEDEL/form.htm

Any help clearing my mess up is beautiful:-)

/Paul

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif