Jorg,
not directly related... but...
when I was F-ing around with LEP trying to get a file manipulator working, on 
Windows the command xcopy gave me the same sort of result

the command line when supplied to the command prompt worked. when supplied 
through LEP failed.
Now again, not Mac, and not v18, it was v15, but I think there are some command 
line actions which - for whatever reason just do not work through LEP

all of that said...
you might want to try to use the following code for your POSIX conversion, note 
there are a lot of references to Konstants in this code, also you can ignore or 
replace the "errutl_xxxx" references as this returns an error code to the call 
stack indicating what and where an error occurred.  Again, not v18, but the 
POSIX command does not correctly convert everything.
I have some code (See below) which should do the conversion correctly

Also... I have code picked up from Kiesuke which escapes the command line 
command - also follows
I hope either of these help.

Chip


  //(m) fileutl_LEP_Escape
  //$1 - Text - path or command to escape

  //Code from Kiesuke Myako - Sublaunch demo

  //RETURNS - Text - escaped path or command
  // • Created 04-13-18 by Chip - 
C_TEXT($1;$0;$Source;$Metacharacter;$Metacharacters)
C_LONGINT($i;$len)
C_BOOLEAN($Needs_Quote)

If (Count parameters#0)
$Source:=$1

If (Folder separator=BackSlash_Char)  //Windows
  //argument escape for cmd.exe
$Needs_Quote:=False
$Metacharacters:="&|<>()%^\" "
$len:=Length($Metacharacters)

For ($i;1;$len)
$Metacharacter:=Substring($Metacharacters;$i;1)
$Needs_Quote:=$Needs_Quote | (Position($Metacharacter;$Source;*)#0)

If ($Needs_Quote)
$i:=$len
End if 
End for 

If ($Needs_Quote)

If (Substring($Source;Length($Source))="\\")
$Source:="\""+$Source+"\\\""
Else 
$Source:="\""+$Source+"\""
End if 
End if 
Else 
$Metacharacters:="\\!\"#$%&'()=~|<>?;*`[] "

For ($i;1;Length($Metacharacters))
$Metacharacter:=Substring($Metacharacters;$i;1)
$Source:=Replace string($Source;$Metacharacter;"\\"+$Metacharacter;*)
End for 
End if 
End if 
$0:=$Source
  //End fileutl_LEP_Escape 




  //fileutl_Path_Convert_to_Posix
  // $1 - Text - Path to convert
  //$2 - Pointer (Optional) - to Error Return Text

  //Original from JorgeChB via iNug

  //Converts a Mac file path to a Posix form

  //RETURNS - Text - converted path, or empty string if path is empty
  // • Created 3/24/15 by Chip - 
  //• Updated 05-17-18 by Chip - added test for empty path
C_TEXT($Path;$Path;$0;$msg)
C_POINTER($2;$Error_ptr)

errutl_Start 

If (Count parameters>=1)
$Path:=$1

If (Count parameters>=2)
$Error_ptr:=$2
End if 

Case of 
: ($Path="")
$msg:="Source Path is empty"
errutl_Add ($msg)

: (Position(Colon_Char;$Path)>0)

If ($Path#"")
$Path:=Replace string($Path;Slash_Char;"__-sLaSh-__")  //'a/b' -> 
'a__-sLaSh-__b'
$Path:=Replace string($Path;Colon_Char;Slash_Char)  //'a:b' -> 'a/b'
$Path:=Replace string($Path;"__-sLaSh-__";Colon_Char)  //'a__-sLaSh-__b' -> 
'a:b'
$Path:=Replace string($Path;BackSlash_Char;BackSlash_Char+BackSlash_Char)  
//'a\\b' -> 'a\\b'"
$Path:=Replace string($Path;Space_Char;BackSlash_Char+Space_Char)  //'a b' -> 
'a\ b'
$Path:=Replace string($Path;"*";BackSlash_Char+"*")  //'a*b' -> 'a\*b'
$Path:=Replace string($Path;"'";BackSlash_Char+"'")  //'a'b' -> 'a\'b'
$Path:=Replace string($Path;"&";BackSlash_Char+"&")  //'a&b' -> 'a\&b'
$Path:=Replace string($Path;Quote_Char;BackSlash_Char+Quote_Char)  //'a"b' -> 
'a\"b'
$Path:=Replace string($Path;"(";BackSlash_Char+"(")  //'a(b' -> 'a\(b'
$Path:=Replace string($Path;")";BackSlash_Char+")")  //'a)b' -> 'a\)b'
$Path:=Replace string($Path;"|";BackSlash_Char+"|")  //'a|b' -> 'a\|b'

  //make sure we do not prepend 'Volumes' if it already there
If (Position("/Volumes/";$Path)=0)
$0:="/Volumes/"+$Path
Else 
$0:=$Path
End if 
Else 
errutl_Add ("Source is empty.")
End if 
Else 
$msg:="Posix conversion is only applicable "
$msg:=$msg+"to paths formatted for use on a Macintosh."
errutl_Add ($msg)
End case 
Else 
$msg:="Required parameters (1) not passed."+Cr_Char
$msg:=$msg+"Parameters passed "+String(Count parameters)
errutl_Add ($msg)
End if 

errutl_End (Current method name;$Error_ptr;Nil($Error_ptr))
  //End fileutl_Path_Convert_to_Posix
> On Mar 4, 2021, at 7:59 AM, Jörg Knebel via 4D_Tech <[email protected]> 
> wrote:
> 
> 
> G’day All,
> 
> We are talking Mac ONLY - High Sierra and Catalina!
> 
> I found a command line application that can take a snapshot with the current 
> camera.
> 
> This nifty tool is called “imagesnap” and it is totally free in all regards.
> 
> Check out: http://iharder.sourceforge.net/current/macosx/imagesnap/ 
> <http://iharder.sourceforge.net/current/macosx/imagesnap/>
> 
> So, I placed that tool in the resource folder of the application I’m working 
> on and tried to call it from within 4D via LEP:
> 
> <4D code>
> 
> C_TEXT($cmd)
> C_TEXT($FoDoPath;$OutPictPath;$imageSnapPath)
> C_BLOB($StdIn;$StdOut;$Error)
> C_LONGINT($PID)
> 
> $FoDoPath:=Get 4D folder(Current resources folder)
> $FoDoPath:=Convert path system to POSIX($FoDoPath)
> 
> $cmd:=$FoDoPath+"./imagesnap -w 2.0 "
> 
> LAUNCH EXTERNAL PROCESS($cmd;$StdIn;$StdOut;$StdOut;$PID)
> 
> </4D code>
> 
> Result: The camera shows activity, but no picture is saved nowhere.
> 
> And now comes the voodoo I don’t get:
> 
> I copied the content from “$cmd” out of the 4D-debugger and paste it into the 
> terminal and got a jpg-picture saved into the current user account (it seems 
> “imagesnap" has some problems with user specified destinations).
> 
> The “$cmd” in my case contains this: 
> /DATA/4Dƒ/TTTCorev18/TTTCorev18.4dbase/Resources/./imagesnap -w 2.0 
> 
> Please tell me we can blame 4D for another botched implementation.
> 
> Any help, pointers etc. are appreciated.
> 
> Cheers
> Jörg
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> New Forum: https://discuss.4D.com
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to