0
votes

I am running the following command through shell_exec but I'm getting the following Warning. The command isn't executing on the server.

$output=shell_exec ("awk -F'\t' '/\[Data\]/{f=1;next} /^$/{f=0} f{gsub(/\t/,",");print}' 1.tsv > 2.csv");

Warning: Wrong parameter count for shell_exec() in /Applications/MAMP/htdocs/output/u.php on line 3

I tried using system and passthru but they result in fatal errors.

Whats wrong? I'm passing only one parameter in shell_exec.

1
Escape internal quotes.. Like this f{gsub(/\t/,\",\") - Cheery
You need an editor with syntax hightlighting. - mario
You have unescaped double quotes " in your argument, making it two strings - Pekka
@mario you are right.. I'm using pico.. Couldn't catch this small thing..thanks - Ank

1 Answers

4
votes

You forgot to escape the string, there are "," in your sting:

$output=shell_exec ("awk -F'\t' '/\[Data\]/{f=1;next} /^$/{f=0} f{gsub(/\t/,\",\");print}' 1.tsv > 2.csv");