Publication date: 04/12/2021

Connect to a Network Directory

On Windows, you can connect to a network directory without connecting to the shared drive first.

Files in Directory( "\\" );

On macOS, you have to mount the volume first and then connect to the directory using a combination of JSL and AppleScript. Note that you can also modify this script to work on Windows. On macOS only, the user is prompted for a password.

mount = Function( {server},
	{Default Local},
	If( Host is( "Mac" ),

/* Use osascript to mount the volume.

The user will be prompted for credentials. */

		Run Program(
			Executable( "/usr/bin/osascript" ),
			Options( {"-e", Eval Insert( "mount volume \!"smb://^server^\!"" )} ),
			Read Function( "text" )
		server = Concat Items( Remove( Words( server, "/" ), 1 ), "/" );
		Eval Insert( "/Volumes/^server^" );

// Windows can use UNC to auto-mount the server.

		Eval Insert( "\!\\!\^server^" )
users = Mount( "" );
Files In Directory( Eval Insert( "^users^/Smith" ) );
Want more information? Have questions? Get answers in the JMP User Community (