Mount network Path and LEP

Dear,

I am using http://kb.4d.com/assetid=77125 to map a network drive.
Mac and v15r5 (32 bit).

However it never shows an error even if the login fails.

In the part where LEP is asking to connect:

	$LEP_Command:="open smb://"+$username+":"+$password+"@"+$server_path
	LAUNCH EXTERNAL PROCESS($LEP_Command;$in;$out;$error)		
	If ($error="")
		$0:="Success"  // success
	Else 
		$0:=$error  // error on the LAUNCH EXTERNAL PROCESS
	End if 

the error parameter is always empty. Even if login fails.

It seems also to be running asynchronous. I believe this because the OSX login dialog
is showing long after the 4D code leaves the LEP call in the debugger.
I have tried the Set Environment variable all possible ways.

What am I not understanding?

Best Regards

Magnus Torell

Try this:

http://forums.4d.com/4DBB_Main/x_User/3906/files/23534846.zip

<code 4D>
// Method 4DDOC_Mount_volume
//
//
// #SYNTAX: $L_Erreur:=4DDOC_Mount_volume(object;->messagetxt)
// #PARAMETERS:
// $0 Long : error code. 1 = OK
// $1 Object : object avec les paramètres
// $2 Pointer : message d’erreur

// #DATE CREATION: 20/12/2017 #AUTHOR: Bertrand SOUBEYRAND info@soubeyrand-4d-developer.eu
// #DATE MODIFICATION: 00/00/0000
// #NOTE:

// #HEADER VERSION: 2

//C_OBJECT($O_Object)
//OB SET($O_Object;“ip”;<>T_Serveur_IP_C)
//OB SET($O_Object;“user”;<>T_Serveur_User_C)
//OB SET($O_Object;“password”;<>T_Serveur_Pass_C)
//OB SET($O_Object;“volume”;$T_SharedFolder_C)
//OB SET($O_Object;“plateforme”;“M”)
//OB SET($O_Object;“protocole”;“smb”)

C_LONGINT($0;$L_MyError) // 0 si le volume ne peut pas être monté
$L_MyError:=1

C_OBJECT($1;$O_Object)
$O_Object:=$1
C_POINTER($2;$P_Message)
$P_Message:=$2

C_TEXT($T_IP;$T_User;$T_Pass;$T_Volume;$T_Plateforme;$T_Protocole)
$T_IP:=OB Get($O_Object;“ip”;Is text)
$T_User:=OB Get($O_Object;“user”;Is text)
$T_Pass:=OB Get($O_Object;“password”;Is text)
$T_Volume:=OB Get($O_Object;“volume”;Is text)
$T_Plateforme:=OB Get($O_Object;“plateforme”;Is text)
$T_Protocole:=OB Get($O_Object;“protocole”;Is text)

Case of
: ($T_Plateforme=“M”)

	C_TEXT($T_Protocole)
	C_TEXT($T_Applescript;$T_Command;$in;$out;$err)
	Case of 
		: ($T_Protocole="SMB")
		: ($T_Protocole="AFP")
		Else 
			$L_MyError:=-1
	End case 
	
	If ($L_MyError=1)
		
		$T_Protocole:=Lowercase($T_Protocole)
		$T_Applescript:="mount volume \""+$T_Protocole+"://"+$T_User+":"+$T_Pass+"@"+$T_IP+"/"+$T_Volume+"\""
		$T_Command:="osascript -e '"+$T_Applescript+"'"
		LAUNCH EXTERNAL PROCESS($T_Command;$in;$out;$err)
		
		If (OK#1)
			$L_MyError:=-2
		End if 
	End if 
	
: ($T_Plateforme="W")
	
	ALERT("pas testé")
	
	C_TEXT($T_Lettre_Drive;$T_Server_path)
	$T_Lettre_Drive:=Replace string($T_Lettre_Drive;":";"")
	$T_Lettre_Drive:=Uppercase($T_Lettre_Drive)
	
	C_LONGINT($L_Code)
	$L_Code:=Character code($T_Lettre_Drive)
	
	C_BOOLEAN($B_Drive)
	$B_Drive:=($L_Code>=65) & ($L_Code<=90)
	ASSERT($B_Drive;"Wrong letter for the drive")
	
	$T_Lettre_Drive:=$T_Lettre_Drive+":"
	
	ASSERT(Length($T_Server_path)>0;"Path to volume is empty")
	While ($T_Server_path[1]="\\")
		$T_Server_path:=Substring($T_Server_path;2)
	End while 
	
	If (Test path name($T_Lettre_Drive)#Is a folder)
		
		C_TEXT($T_LEP;$T_Auth)
		$T_Auth:=Choose($T_User#"";" /user:"+$T_User+" "+$T_Pass;"")
		$T_LEP:="net use "+$T_Lettre_Drive+" \\\\"+$T_Server_path+$T_Auth
		
		C_TEXT($in;$out;$error)
		$in:=""
		SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true")
		LAUNCH EXTERNAL PROCESS($T_LEP;$in;$out;$error)
		
		If (Not(Is nil pointer($P_Message)))
			$P_Message->:="OUT: "+$out+" ERROR: "+$error
		End if 
		
	End if 
	
Else 
	$L_MyError:=-3

End case

C_TEXT($T_Message)
Case of
: ($L_MyError=-1)
$T_Message:="Le protocole n’est pas AFP ou SMB. Resultat: "+$T_Protocole
: ($L_MyError=-2)
$T_Message:=$err
: ($L_MyError=-3)
$T_Message:="Erreur développeur pas de sélecteur pour monter le volume. Resultat: "+$T_Plateforme
Else
$T_Message:=“OK”
End case

$P_Message->:=$T_Message

$0:=$L_MyError

// EOM
</code 4D>

Thanks Bertrand,

Your code was an improvement on the subject. I have tested both
the Windows and the Mac cases and they work fine both.

As another approach I tested the generated “paths” with
OPEN URL(“smb://user:password@ip.address/folder”)
(i’m not sure of the exact syntax above, but it was similar to the generated one)

At least on Mac it did work also.
Maybe this is a cross platform solution. I will try later.

Best Regards and thanks

Magnus