Skip to main content

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?

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


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?

 


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

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.

 

 


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.


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 ;)

 


 

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

 

Yes, you're definitely right ;-)

 

 


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.

 


Reply