0

I am using 'antiword' to convert MSword document to text. I have a file with name "care job house keeper catering job13806.doc" and antiword cannot read this if passed in script.

  public function Convert($filenames) {         
    return $content = shell_exec('antiword'." ".$filenames.' -');//dash at the end to output content        
}

If a manually enter filename by typing antiword and pressing tab after few charters of filename it looks as below and executes perfectly.

$ antiword care\ job\ housekeeper\ catering\ job13806.doc
manojkumar
  • 29
  • 1
  • 7

1 Answers1

0

Use quotes:

shell_exec("antiword '$filename' -");

That'd produce:

antiword 'care job housekeeper catering job13806.doc' -
Marc B
  • 356,200
  • 43
  • 426
  • 500
  • but I want to put this in a script. there are thousands of files....below is my script to put "\" in place of " " in between filename... but it is displaying error.. $file1=str_replace(" "," \",$file1); – manojkumar Jun 05 '12 at 14:39
  • don't do that. use [escapeshellarg](http://php.net/manual/en/function.escapeshellarg.php) instead. – Marc B Jun 05 '12 at 14:42
  • Hi , actually escapeshellcmd got worked instead of escapeshellarg... but '\' is not getting before ',' in file names.. example: catering job,bar mam,customer service1924.doc - not working , but for cv done \(1\)14339.doc- working. – manojkumar Jun 05 '12 at 16:08