Skip to main content
Solved

Shutdown script + run system command

  • August 17, 2016
  • 8 replies
  • 36 views

Forum|alt.badge.img

I have a Shutdown Python Script wich run a system terminal command.

 

In this command I have to write the name of different pdf files. My problem is that the names are written directly in the command. I prefer to write the name of a variable wich refers to a file name.

 

Is that possible in the shutdown Python script?

I also find the transformer SystemCaller. Maybe it's a better idea. But, my script have to be run à the very end of the project.

Do you have any advice please?

Best answer by takashi

Hi @slerendu, the "os.system" method may be what you are looking for. See here: os.system

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

8 replies

takashi
Celebrity
  • Best Answer
  • August 17, 2016

Hi @slerendu, the "os.system" method may be what you are looking for. See here: os.system


Forum|alt.badge.img
  • Author
  • August 17, 2016

Hi @slerendu, the "os.system" method may be what you are looking for. See here: os.system

Ok, let me update the question a little.

 

If I run the cmd_03, everything is fine.

 

But if I run the cmd_04, the log tells me :

 

Error: Unable to find file.

Error: Failed to open PDF file:

 

myOrigFileWhat do you think?

 


takashi
Celebrity
  • August 17, 2016

Hi @slerendu, the "os.system" method may be what you are looking for. See here: os.system

Since the error messages are from the command, you will have to find the reason according to the specification of the command, but maybe you need to replace the string "myOrigFile" within the cmd_04 string with the actual file name (i.e."cerfa_Response_DT_DICT_pdf"). e.g.

 

pdftk_cmd_04 = "pdftk %s result\83*.pdf cat output newfile2.pdf" % myOrigFile

Forum|alt.badge.img
  • Author
  • August 17, 2016
Since the error messages are from the command, you will have to find the reason according to the specification of the command, but maybe you need to replace the string "myOrigFile" within the cmd_04 string with the actual file name (i.e."cerfa_Response_DT_DICT_pdf"). e.g.

 

pdftk_cmd_04 = "pdftk %s result\83*.pdf cat output newfile2.pdf" % myOrigFile
Perfect! This is clearly a developer subtle thing. Thanks.

 

 


Forum|alt.badge.img

Since your python script looks like sending this command is its only job you can also think about using the system caller transformer. Before FME2016 you had no chance to write something out and manipulate the results afterwards without using python shutdown scripts. In FME 2016 you can write files with the new feature writer transformer and manipulate them afterwards with e.g. the system caller.


Forum|alt.badge.img

Since your python script looks like sending this command is its only job you can also think about using the system caller transformer. Before FME2016 you had no chance to write something out and manipulate the results afterwards without using python shutdown scripts. In FME 2016 you can write files with the new feature writer transformer and manipulate them afterwards with e.g. the system caller.

 

... but your user avatar tells me that you like to use python ;)

 


Forum|alt.badge.img
  • Author
  • August 18, 2016

 

... but your user avatar tells me that you like to use python ;)

 

Yes, you're definitely right ;-)

 

 


Forum|alt.badge.img
  • Author
  • August 18, 2016

Since your python script looks like sending this command is its only job you can also think about using the system caller transformer. Before FME2016 you had no chance to write something out and manipulate the results afterwards without using python shutdown scripts. In FME 2016 you can write files with the new feature writer transformer and manipulate them afterwards with e.g. the system caller.

Ok. It's good to know. Actually, I'm working on a 2015 version for now. So I keep that advice in mind. Thanks.