We help top organizations stay competitive, by implementing the latest disruptive technologies.

Latest Posts

Efficiently Transfer Files to an OS X Device with SDClient

Efficiently Transfer Files to an OS X Device with SDClient

Have you ever needed to copy a file from a share to a more than one Mac in your environment?  My guess is the answer to that is yes, I know it was for the potential customer I spoke with on the phone today.  Whether you’re trying to apply a configuration file for a package, settings for a proxy server, VPN configuration files or any of the myriad of other reasons, what you’re transferring isn’t the important question, it’s how do you do it.

Luckily sdclient, the tool that is the brains behind all things software distribution for the Mac, has a bunch of goodness via command line switches that can be used to download files and place them into specific locations; all the while still taking advantage of the download technologies built into the agent.

To leverage sdclient, we’ll write a shell script that will tell sdclient what file to download and where to place it.  The entire script is very short.  There will be two variables, one for the source file location and the second for the destination location.

The only thing you need to really pay attention to in regards to the source location is to ensure the file is accessible via http.  You can setup a variable or just supply the location.  I like to create a variable so that the code can be better documented and easier to read for others.  Here is my source variable.


We’ll repeat the process for the destination location.


In addition to the destination variable, the script will include a quick check to ensure the destination folder exists on the end node and if not, create it.

if [ ! -d "$destinationLocation" ]; then
echo "Location doesn't exist.  Creating directory"
mkdir $destinationLocation
echo "$destinationLocation created"

The actual download and placement of the file will be done by sdclient with three switches: -noinstall, -package and –destdir.  The switch names are pretty self-explanatory, the –noinstall tells sdclient to not execute the file that will be downloaded.  The –package switch is where you insert the path to the source file available, again available on the http share.  Lastly, the –destdir switch tells sdclient where to place the file on the Mac client.

All done, your command sdclient command should look something like:

/Library/Application\ Support/LANDesk/bin/sdclient -noinstall -package "$fileToCopy" -destdir "$destinationLocation"

Here is the entire example script.

#  FileTransfer.sh
#  Created by Bennett Norton on 5/16/16.
#  This script will copy a file from the source destination and place it on the Mac into the destination folder
#  Change the path variables

#File to copy
#change this to match your hosted path, it needs to be http

#Location to copy file to
#change this to match your destination path
destinationLocation="/Path/To/Your/Destination/Folder "

#Check to see if destination exists and if not, create it
if [ ! -d "$destinationLocation" ]; then
echo "Location doesn't exist.  Creating directory"
mkdir $destinationLocation
echo "$destinationLocation created"

#Download and execute command
#You shouldn't need to make any changes here
#-noinstall ensure the package does not get executed
#-package is the source url path
#-destdir is the destination url path
/Library/Application\ Support/LANDesk/bin/sdclient -noinstall -package "$fileToCopy" -destdir "$destinationLocation"

As discussed in previous posts, save this file as a .sh file and set the execute permission on it by running the command below.

sudo chmod +x /path/to/script.sh

Once you’ve set the execute permissions, copy the script to your package repository and create a LANDESK Software Distribution package to deploy.

Creating LANDESK Management Suite Mac Packages

  1. Open the LANDESK Console
  2. Navigate to the top menu bar, select Tools > Distribution > Distribution Packages.
  3. In the lower left menu tree, highlight My Packages or Public Packages from within the Distribution Packages window
  4. On the Distribution menu bar, press the New Package button and select New Macintosh Package.
  5. Give the package a name
  6. Provide a description as well as any metadata information desired
  7. Set the primary file to the script file you previously transferred to your package share
  8. Fill out the Metadata details if desired, specifically supplying a logo so it shows up properly in the portal
  9. Save the package

Creating a Scheduled Mac Software Distribution Task

  1. Right click on the Mac software distribution package created and select Create Scheduled Task
  2. From the network view, select and drag the desired machine(s), user(s) or query(ies) and drop them onto the task
  3. Now, right click on the task and select properties
  4. Set the desired Task type under Task Settings as to whether you want a push, a policy or a hybrid of the two types in a policy-supported push
  5. Set the radio button in the Portal Settings to either Recommended or Optional if you desire to put the package into Workspaces.  If you’d like to automatically deploy the app, select Run automatically
  6. Change the Reboot Settings or Distribution and Patch settings if desired
  7. Set the schedule task settings with the appropriate start time


  • Jerry Horn
    Posted at 09:22h, 02 December Reply

    How would you copy a shell script file down and run it?

    Here is my LD script I created in Managed Scripts.

    REMEXEC01=sdclient –noinstall –package http://%CUSTJOBHOSTIP%/software/MAC/Kaspersky/kesmac10_0_0_327m/51772D39.key -destdir /Library/Application Support/LANDesk/sdcache
    REMEXEC02=sdclient –noinstall –package http://%CUSTJOBHOSTIP%/software/MAC/Kaspersky/kesmac10_0_0_327m/install.sh -destdir /Library/Application Support/LANDesk/sdcache
    REMEXEC03=sdclient –noinstall –package http://%CUSTJOBHOSTIP%/software/MAC/Kaspersky/kesmac10_0_0_327m/kesmac.dmg -destdir /Library/Application Support/LANDesk/sdcache
    REMEXEC04=sdclient –noinstall –package http://%CUSTJOBHOSTIP%/software/MAC/Kaspersky/kesmac10_0_0_327m/kesmac.kud -destdir /Library/Application Support/LANDesk/sdcache
    REMEXEC05=sdclient –noinstall –package http://%CUSTJOBHOSTIP%/software/MAC/Kaspersky/kesmac10_0_0_327m/license_en.txt -destdir /Library/Application Support/LANDesk/sdcache
    REMEXEC06=sudo /Library/Application Support/LANDesk/sdcache/install.sh

    • Bennett
      Posted at 23:05h, 03 December Reply

      You don’t need to add sudo to your script as it is already running as root – that may be the cause itself of the failure. Also, I don’t use Managed Scripts. Just write your .sh file, set the execute permissions and then create a standard Mac Package and deploy it out just as you would an application.

      Example script below:


      # Created by Bennett Norton on 12/3/16.
      # This script will download a set of files and execute the script

      #Script Variables
      #change the IP address to match your core server IP address
      destinationDirectory=”/Library/Application Support/LANDesk/sdcache”

      #sdclient downloads the files
      /Library/Application Support/LANDesk/bin/sdclient -noinstall -package “$filePath””/51772D39.key” -destdir “$destinationDirectory”
      /Library/Application Support/LANDesk/bin/sdclient -noinstall -package “$filePath””/install.sh” -destdir “$destinationDirectory”
      /Library/Application Support/LANDesk/bin/sdclient -noinstall -package “$filePath””/kesmac.dmg” -destdir “$destinationDirectory”
      /Library/Application Support/LANDesk/bin/sdclient -noinstall -package “$filePath””/kesmac.kud” -destdir “$destinationDirectory”
      /Library/Application Support/LANDesk/bin/sdclient -noinstall -package “$filePath””/license_en.txt” -destdir “$destinationDirectory”

      # run the installer script
      /Library/Application Support/LANDesk/sdcache/install.sh

  • Nine41 Consulting | Have You Ever Needed to Send a Notification or an Alert to Your Entire Organization?
    Posted at 10:07h, 21 February Reply

    […] Therefore, all you need to do at this point is write a script that will download your Script Editor application and run it. We will still use SDClient in our script, giving us bandwidth controls and peer sharing. For more information on creating such scripts, see my blog post on efficiently transferring files with sdclient. […]

Post A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.