Running weka from php

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Running weka from php

kritish
Hi, I have been experiencing some problems running a command using the
shell_exec() function in php. The php page returns nothing.
The following is the faulty piece of code.


<?php

$command = 'java -cp
"C:\Users\kritish\Desktop\FinalYearProject\MachineLearningTools\Weka-3-8\weka.jar"
weka.classifiers.meta.FilteredClassifier -t
C:\xampp\htdocs\VerificationOfDocs\hscr.arff -T
C:\xampp\htdocs\VerificationOfDocs\hsc_test.arff -p 0 -F
"weka.filters.unsupervised.attribute.StringToWordVector -R first-last -W
1000 -prune-rate -1.0 -N 0 -stemmer weka.core.stemmers.NullStemmer
-stopwords-handler weka.core.stopwords.Null -M 1 -tokenizer
\"weka.core.tokenizers.WordTokenizer -delimiters \\\"
\\\\r\\\\n\\\\t.,;:\\\\\\\'\\\\\\\"()?!\\\"\"" -S 1 -W
weka.classifiers.trees.J48 -- -C 0.25 -M 2';
$output = shell_exec($command);
echo "<pre>$output</pre>";

?>



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Running weka from php

Peter Reutemann
> Hi, I have been experiencing some problems running a command using the
> shell_exec() function in php. The php page returns nothing.
> The following is the faulty piece of code.
>
>
> <?php
>
> $command = 'java -cp
> "C:\Users\kritish\Desktop\FinalYearProject\MachineLearningTools\Weka-3-8\weka.jar"
> weka.classifiers.meta.FilteredClassifier -t
> C:\xampp\htdocs\VerificationOfDocs\hscr.arff -T
> C:\xampp\htdocs\VerificationOfDocs\hsc_test.arff -p 0 -F
> "weka.filters.unsupervised.attribute.StringToWordVector -R first-last -W
> 1000 -prune-rate -1.0 -N 0 -stemmer weka.core.stemmers.NullStemmer
> -stopwords-handler weka.core.stopwords.Null -M 1 -tokenizer
> \"weka.core.tokenizers.WordTokenizer -delimiters \\\"
> \\\\r\\\\n\\\\t.,;:\\\\\\\'\\\\\\\"()?!\\\"\"" -S 1 -W
> weka.classifiers.trees.J48 -- -C 0.25 -M 2';
> $output = shell_exec($command);
> echo "<pre>$output</pre>";
>
> ?>

Are you running PHP in safe mode? See notes here:
https://www.php.net/manual/en/function.shell-exec.php

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Running weka from php

kritish
I found out that safe is off by default in the current version of php. Also, the command works perfectly fine using the command line.
Do you think that the errors are maybe due to amount of special characters in the command?

Thank you for your help.

On Sat, 1 Feb 2020 at 23:50, Peter Reutemann <[hidden email]> wrote:
> Hi, I have been experiencing some problems running a command using the
> shell_exec() function in php. The php page returns nothing.
> The following is the faulty piece of code.
>
>
> <?php
>
> $command = 'java -cp
> "C:\Users\kritish\Desktop\FinalYearProject\MachineLearningTools\Weka-3-8\weka.jar"
> weka.classifiers.meta.FilteredClassifier -t
> C:\xampp\htdocs\VerificationOfDocs\hscr.arff -T
> C:\xampp\htdocs\VerificationOfDocs\hsc_test.arff -p 0 -F
> "weka.filters.unsupervised.attribute.StringToWordVector -R first-last -W
> 1000 -prune-rate -1.0 -N 0 -stemmer weka.core.stemmers.NullStemmer
> -stopwords-handler weka.core.stopwords.Null -M 1 -tokenizer
> \"weka.core.tokenizers.WordTokenizer -delimiters \\\"
> \\\\r\\\\n\\\\t.,;:\\\\\\\'\\\\\\\"()?!\\\"\"" -S 1 -W
> weka.classifiers.trees.J48 -- -C 0.25 -M 2';
> $output = shell_exec($command);
> echo "<pre>$output</pre>";
>
> ?>

Are you running PHP in safe mode? See notes here:
https://www.php.net/manual/en/function.shell-exec.php

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Running weka from php

Michael Hall


On Feb 2, 2020, at 5:38 AM, Kritish Appadu <[hidden email]> wrote:

Do you think that the errors are maybe due to amount of special characters in the command?

If you echo the command itself does it look as expected?


_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Running weka from php

kritish
I tried to do that and it does not return the original command (some of the backslashes are deleted). Thank you for helping me out.

On Mon, 3 Feb 2020, 06:52 Michael Hall, <[hidden email]> wrote:


On Feb 2, 2020, at 5:38 AM, Kritish Appadu <[hidden email]> wrote:

Do you think that the errors are maybe due to amount of special characters in the command?

If you echo the command itself does it look as expected?

_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Running weka from php

Peter Reutemann-3
On February 3, 2020 8:46:58 PM GMT+13:00, Kritish Appadu <[hidden email]> wrote:

>I tried to do that and it does not return the original command (some of
>the
>backslashes are deleted). Thank you for helping me out.
>
>On Mon, 3 Feb 2020, 06:52 Michael Hall, <[hidden email]> wrote:
>
>>
>>
>> On Feb 2, 2020, at 5:38 AM, Kritish Appadu <[hidden email]>
>wrote:
>>
>> Do you think that the errors are maybe due to amount of special
>characters
>> in the command?
>>
>>
>> If you echo the command itself does it look as expected?
>>
>> _______________________________________________
>> Wekalist mailing list -- [hidden email]
>> Send posts to: To unsubscribe send an email to
>> [hidden email]
>> To subscribe, unsubscribe, etc., visit
>>
>https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
>> List etiquette:
>> http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
>>

Double up your backslashes in your command.

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Running weka from php

kritish
The problem is solved now. Very grateful for your help. 
Cheers


On Mon, 3 Feb 2020 at 13:31, Peter Reutemann <[hidden email]> wrote:
On February 3, 2020 8:46:58 PM GMT+13:00, Kritish Appadu <[hidden email]> wrote:
>I tried to do that and it does not return the original command (some of
>the
>backslashes are deleted). Thank you for helping me out.
>
>On Mon, 3 Feb 2020, 06:52 Michael Hall, <[hidden email]> wrote:
>
>>
>>
>> On Feb 2, 2020, at 5:38 AM, Kritish Appadu <[hidden email]>
>wrote:
>>
>> Do you think that the errors are maybe due to amount of special
>characters
>> in the command?
>>
>>
>> If you echo the command itself does it look as expected?
>>
>> _______________________________________________
>> Wekalist mailing list -- [hidden email]
>> Send posts to: To unsubscribe send an email to
>> [hidden email]
>> To subscribe, unsubscribe, etc., visit
>>
>https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
>> List etiquette:
>> http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
>>

Double up your backslashes in your command.

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html