Execute Command
-
- Newbie
- Posts: 8
- Joined: Tue May 30, 2023 2:43 pm
Execute Command
Hello,
So I have been trying to get the execute command to work for a little bit now and I can't seem to get it right. What I want to do is have my input files (PDF) gets put into the execute command that would trigger my script to run. My script will take the PDF files and string out parts of the text using OCR then lay it out on a json file. I was told to use arguments for my input and output folders ("%1" and "%3"). I also turned on my log and I can see that switch is executing the file path to my script (/Applications/MAMP/htdocs/Arg.py) along with the arguments but I still get output folders that don't have anything inside of them. I see that it's trying to execute something which is why I don't understand why I'm getting blank folders as the output. if anyone has any tips or tricks I can try to get this up and running that would be great!
Thank you
So I have been trying to get the execute command to work for a little bit now and I can't seem to get it right. What I want to do is have my input files (PDF) gets put into the execute command that would trigger my script to run. My script will take the PDF files and string out parts of the text using OCR then lay it out on a json file. I was told to use arguments for my input and output folders ("%1" and "%3"). I also turned on my log and I can see that switch is executing the file path to my script (/Applications/MAMP/htdocs/Arg.py) along with the arguments but I still get output folders that don't have anything inside of them. I see that it's trying to execute something which is why I don't understand why I'm getting blank folders as the output. if anyone has any tips or tricks I can try to get this up and running that would be great!
Thank you
- Attachments
-
- Screen Shot 2023-11-09 at 10.31.30 AM.png (88.38 KiB) Viewed 22096 times
-
- Execute Command ScreenShots.zip
- Here is my script
- (213.45 KiB) Downloaded 1127 times
- magnussandstrom
- Advanced member
- Posts: 376
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: Execute Command
I would use the app 'Execute Command Friend' for this task.
-
- Newbie
- Posts: 8
- Joined: Tue May 30, 2023 2:43 pm
Re: Execute Command
Is there any way to do this task with the execute command?
Re: Execute Command
There is a flaw in the setup of "Execute command". You have to consider that "Execute command" is like running a command on the command line (Terminal or Command prompt). If you were to type the path of the Python script the operating system would also complain. You have to run Python and the script is one of the parameters. Likewise in "Execute command" "Command or path" has to point to Python and the script path goes into the "Arguments".
- magnussandstrom
- Advanced member
- Posts: 376
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: Execute Command
I found an old flow where I executed a Python script with Execute command, here are my settings:
Arguments on this case are:
Arguments on this case are:
Code: Select all
C:\Users\color\Documents\image-background-remove-tool\main.py -i "%1" -o "%3\[Job.NameProper].png" -m u2net
-
- Newbie
- Posts: 8
- Joined: Tue May 30, 2023 2:43 pm
Re: Execute Command
Hello,
So I changed a few things but I don't think that my script is being run. I set up a test that should change the text in the output file when the script is running but I don't see any changes which is why I'm assuming that my script is not being run. Looking at the logs I noticed that there are quotation marks that are being added to the path that leads to my script. I don't know if this is a switch thing or what is happening. Is there something that I'm missing?
So I changed a few things but I don't think that my script is being run. I set up a test that should change the text in the output file when the script is running but I don't see any changes which is why I'm assuming that my script is not being run. Looking at the logs I noticed that there are quotation marks that are being added to the path that leads to my script. I don't know if this is a switch thing or what is happening. Is there something that I'm missing?
- Attachments
-
- Screen Shot 2023-11-28 at 12.41.01 PM.png (46.93 KiB) Viewed 21862 times
-
- Screen Shot 2023-11-28 at 12.41.40 PM.png (6.76 KiB) Viewed 21862 times
-
- Newbie
- Posts: 6
- Joined: Wed Jul 29, 2020 9:27 am
Re: Execute Command
Hi, can you please tell me where I can find detailed instructions on how to work with the execute command tool, I can't get the scripts to work even from the command line
magnussandstrom wrote: ↑Wed Nov 15, 2023 9:44 am I found an old flow where I executed a Python script with Execute command, here are my settings:
python.png
Arguments on this case are:Code: Select all
C:\Users\color\Documents\image-background-remove-tool\main.py -i "%1" -o "%3\[Job.NameProper].png" -m u2net
-
- Newbie
- Posts: 6
- Joined: Wed Jul 29, 2020 9:27 am
Re: Execute Command
Hi everyone, I can't figure out how the execute command tool works, specifically how the %1 %2 %3 arguments work.
For example I want to run a python script.
All json files included in execute command are converted to xml.
I use this script
command and path - C:/Users/enfocus/AppData/Local/Programs/Python/Python312/python.exe
arguments - C:/j2x.py %1 %2
I'm getting two errors
For example I want to run a python script.
All json files included in execute command are converted to xml.
I use this script
Code: Select all
import sys
import os
import json
from dicttoxml import dicttoxml
# Конвертация из JSON в XML
def json_to_xml(input_file, output_folder):
try:
# Имя входного файла без расширения
input_filename = os.path.splitext(os.path.basename(input_file))[0]
# Путь к выходному XML файлу
output_file_path = os.path.join(output_folder, f"{input_filename}.xml")
# Чтение JSON из входного файла
with open(input_file, 'r', encoding='utf-8') as f:
json_data = json.load(f)
# Преобразование JSON в XML без добавления типов данных каждого элемента
xml_data = dicttoxml(json_data, custom_root='root', attr_type=False)
# Запись результата в XML-файл
with open(output_file_path, 'wb') as f:
f.write(xml_data)
print(f"Файл {input_filename}.json успешно преобразован в XML.")
except Exception as e:
print(f"Произошла ошибка при преобразовании {input_filename}.json:", str(e))
# Проверяем переданный путь к файлу и путь к выходной папке
if len(sys.argv) != 3:
print("Использование: python j2x.py input_file output_folder")
else:
input_file = sys.argv[1]
output_folder = sys.argv[2]
json_to_xml(input_file, output_folder)
arguments - C:/j2x.py %1 %2
I'm getting two errors
Code: Select all
Cannot send job: path 'C:/Users/enfocus/AppData/Roaming/Enfocus/Switch Server/temp/294/ScriptElement/2/117/ExecuteComandResult/1443735-1443736.json' does not exist
Code: Select all
Cannot complete sendToSingle() for 'C:/Users/enfocus/AppData/Roaming/Enfocus/Switch Server/temp/294/ScriptElement/2/117/ExecuteComandResult/1443735-1443736.json'
Re: Execute Command
In the execute command app, what setting do you have for the "Output" property? According to the app documentation, this should be "Folder at path" if you want to output a new folder.
However it also looks like you're making a single file inside that folder, so perhaps "File at path" is a better fit. But then you'll have to edit the python script to create the file at %2 - currently it treats %2 as a folder and puts the file inside.
However it also looks like you're making a single file inside that folder, so perhaps "File at path" is a better fit. But then you'll have to edit the python script to create the file at %2 - currently it treats %2 as a folder and puts the file inside.
Re: Execute Command
Not sure if this well help but I use Python via execute command to do some data cleansing
I think like suggested, change your Output to File at Path, we also point to Python in the Command and then in the argument we put the path to the script
Here is my setup.
In the Arguments we have the path to the script in quotes, like this: "/Path to script/script.py" "%1" "%2"
Output : File at path
I think like suggested, change your Output to File at Path, we also point to Python in the Command and then in the argument we put the path to the script
Here is my setup.
In the Arguments we have the path to the script in quotes, like this: "/Path to script/script.py" "%1" "%2"
Output : File at path
Color Science & Workflow Automation
-
- Newbie
- Posts: 6
- Joined: Wed Jul 29, 2020 9:27 am
Re: Execute Command
could you send your python script to understand the structure?
rhd_ole wrote: ↑Thu Jan 18, 2024 3:52 pm Not sure if this well help but I use Python via execute command to do some data cleansing
I think like suggested, change your Output to File at Path, we also point to Python in the Command and then in the argument we put the path to the script
Here is my setup.
In the Arguments we have the path to the script in quotes, like this: "/Path to script/script.py" "%1" "%2"
Output : File at path
Screenshot 2024-01-18 at 8.50.36 AM.png