Passing a variable to a Shell statement

23 views
Skip to first unread message

André Tremblay

unread,
Jul 15, 2018, 9:25:34 PM7/15/18
to SuperCard Discussion
Hello, 

I am having an issue when I try pass an argument as a local variable to a Shell cal to ExifTool. 

The example:

put "-T -d '%y%m%d'" into ArgumentDate

put shell(merge("`[[ChExifTool]]`exiftool `[[ArgumentDate]]` -DateTimeOriginal `[[ChPosixFichier]]`")) into LaDate


I am getting a result as it the ArgumentDate being ignored as a non-valid parameter. 


But I am getting the right result if I am putting the argument literally : 


put shell(merge("`[[ChExifTool]]`exiftool -T -d '%d/%m/%Y' -DateTimeOriginal `[[ChPosixFichier]]`")) into LaDate


Are there incompatible characters in the argument?


Many thanks for your help!


André Tremblay

PhotoGraphex



jen...@adelaide.on.net

unread,
Jul 15, 2018, 11:38:18 PM7/15/18
to SuperCard Discussion
Hi André

Do you need to put quotes around ArgumentDate when it is passed to exiftool?

This is the difference between your your first shell command (with ArgumentDate being passed as a parameter) and your second (with -T -d '%d/%m/%Y' passed directly).

"abcd"exiftool "-T -d '%y%m%d'" -DateTimeOriginal "efgh"
"abcd"exiftool -T -d '%d/%m/%Y' -DateTimeOriginal "efgh"

(For testing I used "abcd" for ChExifTool and "efgh" for ChPosixFichier.)

So perhaps you don't need the gravè accent characters around [[ArgumentDate]] in the merge command.


Here is a hint when you are having trouble with shell commands.

Instead of
put shell(merge("`[[ChExifTool]]`exiftool `[[ArgumentDate]]` -DateTimeOriginal `[[ChPosixFichier]]`")) into LaDate
do it in two steps.

put merge("`[[ChExifTool]]`exiftool `[[ArgumentDate]]` -DateTimeOriginal `[[ChPosixFichier]]`") into tCmd
put shell(tCmd) into LaDate

Then if it's not working, put a trace command between the two lines and the script will pause to show you what you have for the shell command.

Peter Jenkins

André Tremblay

unread,
Jul 16, 2018, 8:18:59 PM7/16/18
to SuperCard Discussion
Hello Peter, 

Do you need to put quotes around ArgumentDate when it is passed to exiftool?

You are right on the cause of the issue, the variable doesn't need to be inclosed between the grave accent characters! 

It does work normally now!

Thank you so much!

 
So perhaps you don't need the gravè accent characters around [[ArgumentDate]] in the merge command.

I should I read the documentation more carefully!

 
Here is a hint when you are having trouble with shell commands.

Instead of
put shell(merge("`[[ChExifTool]]`exiftool `[[ArgumentDate]]` -DateTimeOriginal `[[ChPosixFichier]]`")) into LaDate
do it in two steps.

put merge("`[[ChExifTool]]`exiftool `[[ArgumentDate]]` -DateTimeOriginal `[[ChPosixFichier]]`") into tCmd
put shell(tCmd) into LaDate

Then if it's not working, put a trace command between the two lines and the script will pause to show you what you have for the shell command.

That's a very good suggestion that I've already put to work! It's very useful for clarity!

Thank you again! 

My best regards

André Tremblay
PhotoGraphex
Reply all
Reply to author
Forward
0 new messages