Python Forum
Run Script written in javascript from python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run Script written in javascript from python
#1
Hello everyone !!

I have written a scipt for a program called Javafoil and I want torun it from python.
I Therefore write this command in the python console :

java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript
But I have an error :

Error:
java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript ^ SyntaxError: invalid syntax
I have to admit that this command line was given to me and that I don't really get how it works ...
Can someone help and explain ?

Thanks a lot !!
Scientifix
Reply
#2
You can try
>>> s = 'java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript'
>>> import shlex
>>> command = shlex.split(s)
>>> import subprocess as sp
>>> sp.call(command)
Reply
#3
Tanks Gribouillis !!

But when I run your code I get :
Error:
Error: Could not find or load main class MH.JavaFoil.JavaFoil
What's wrong ? Can you explain me the different parts of a command line such as : java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript ? Maybe it could help ...
Reply
#4
(Apr-28-2018, 04:53 PM)Scientifix Wrote: Can you explain me the different parts of a command line such as : java
This is not a python question: your question is about the syntax of the java command. You could read this or type java -h
or man java in a terminal/console. The exact syntax may depond on your os. For example I read that in linux, the ; in your command must be replaced with :.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,007 Jun-29-2023, 11:57 AM
Last Post: gologica
  How to Translate a python code written in Mac-OS to Windows? alexanderDennisEnviro500 2 2,638 Jul-31-2021, 08:36 AM
Last Post: Gribouillis
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,788 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,247 May-28-2020, 05:27 PM
Last Post: micseydel
  Python script - search Apache access_log.txt for all of the JavaScript (.js) jnovak 7 4,268 May-04-2020, 07:02 AM
Last Post: snippsat
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,583 May-11-2019, 08:12 PM
Last Post: keames
  How to run python script which has dependent python script in another folder? PrateekG 1 3,105 May-23-2018, 04:50 PM
Last Post: snippsat
  How to call one python script and use its output in another python script lravikumarvsp 3 32,286 May-16-2018, 02:08 AM
Last Post: lravikumarvsp
  1st Script written doesn't output anything. Need some else's eyes Kym 3 2,984 Mar-21-2018, 04:19 PM
Last Post: nilamo
  How to use python variable in javascript arun28sharma44 0 3,029 Nov-05-2017, 03:52 PM
Last Post: arun28sharma44

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020