0

I use this code to upload text file to the folder. It works fine, file is in folder. File is named by multimedia id -"mid.txt"(i.e: "1.txt"):

Part of upload.php:

if(isset($_POST['btn-upload']))
{                           
    $folder="/var/www/tmp/textgrid_uploads/$mid.txt";

I want to use the uploaded file "$mid.txt" from "textgrid_uploads" directory in script for conversion. The script "conversion.sh" has defined "input", "output" and "temporary" file because it has to be defined to store temp file:

Part of script "conversion.sh":

mid=$1     
infile="/var/www/tmp/textgrid_uploads/$mid"
outfile="/var/www/tmp/mlf/${mid}.mlf"
tmpfile="/var/www/tmp/mlf/${mid}.tmp"

The script works fine, becasuse I tested it for files which were created manually on server using: vim 1.txt. Problem is when I want to use script "conversion.sh" for file which was uploaded on server using "upload.php". After using script "conversion.sh" It creates blank file called "$mid.mlf" in "mlf" directory with no text. Running of "conversion.sh": i.e: ./conversion.sh 1.txt

specializt
  • 1,913
  • 15
  • 26
Nikolaus
  • 253
  • 2
  • 15
  • Can you pls clarify what exactly you are trying to achieve and what is the exact issue you are facing with your full code and the error displayed? Reading through your question, its unclear as to what you are trying to achieve. – rahul Apr 15 '15 at 12:28
  • @Ingo Karkat: You rejected my _thorough_ suggested edit with your tag-only change. Is there anything one of us could have done to prevent this? – Michael Jaros Apr 15 '15 at 12:30
  • 2
    @MichaelJaros: Yes, sorry. I noticed that, too, but there was no way to undo my action. Best I could have done was grabbing your edit from the side-by-side diff shown to me, and editing that myself (but I found extracting the right-only side too dangerous and cumbersome, and no way to attribute that back to you). You might raise this on Meta StackExchange; it guess that would appropriate. – Ingo Karkat Apr 15 '15 at 12:49
  • How are you calling the script from php? – Etan Reisner Apr 15 '15 at 13:03
  • @Etan Reisner the script is calling in terminal...i.e: "./conversion.sh 1.txt" It works fine for files which I created manually in terminal using "vim" command in the same folder as uploaded files, but script doesn't work for uploaded files using "upload.php". It creates empty files with no content. – Nikolaus Apr 15 '15 at 13:08
  • 1
    That doesn't really make any sense. Are you calling the script the same way for both files? Does the script have a shebang `#!` line at the top? What shell are you using? How **exactly** are you calling it for the uploaded file? What do the uploaded file's contents look like? What do you see if you add `set -x` to the top of the script? – Etan Reisner Apr 15 '15 at 13:14
  • Possibly relevant background: http://stackoverflow.com/questions/29611094/how-to-use-bash-script-input-vs-output – tripleee Apr 15 '15 at 14:06

0 Answers0