1

I have a scenario where I don't want to allow end-user to download the file but I want for them to install the required tool on their Mac machine using the package of FTP. Is there any way that allows the user to run the command from Terminal and execute the package without downloading it. While googling, I saw the option of wget but I am still researching to know whether it is doable or not. Kindly share me your opinion on it.

9
  • 2
    I think you're going to have provide more details of this scenario. The ftp Terminal command was removed from MacOS some time ago. However, you can't really run or install any tool without downloading it somehow. Even wget is a download. – benwiggy Aug 12 '19 at 10:21
  • Welcome to Ask Different! :) I know it can be frustrating when you're trying to do something, however it's vital that you provide us with sufficient details to assist you. Unfortunately, as the question is written it's really not clear what you're asking here? Obviously you can't install something without downloading it first, so is it that you really don't want the download to happen, or is it that you just want the download automatically removed after installation? Or perhaps it's something else you want done? – Monomeeth Aug 12 '19 at 10:30
  • Thank you both for your reply. I need a way that I dont' want end user to downlaod file automatically but I will share the .pkg and want them a way to run that .pkg from terminal without downlaoding or get removed after downloading (will also work for me)? Reason: I have a volume license tool and I have lots of end-user located in a different location. If I start giving them .pkg to download and install, I can't make sure that it will be used in that machine only as VLK file you can have it for home too. So, I am looking for easy and efficient solution and end-user may be a non-technical. – Udhy Aug 12 '19 at 10:40
  • 1
    Running the pkg requires access to it. If a user has access they also can copy the file for later use. This is independent of the technical solution (FTP or other) for the access. – nohillside Aug 12 '19 at 10:47
  • If FTP is not a solution, what can I use so I can share the link of file and can allow a user to install a tool without downloading it? Note: the End user is admin of the machine so I was looking some solution on the terminal, so they can copy/paste my script. – Udhy Aug 12 '19 at 10:50
4

Shell script: curl & installer

If you can host the package on a web site, the installation can be reduced to the following two commands.

  1. Download the file to the local computer:

    /usr/bin/curl https://www.example.com/mypackage.pkg > /tmp/mypackage.pkg
    
  2. Install the downloaded file:

    /usr/sbin/installer -pkg /tmp/mypackage.pkg -target /
    

You can combine these commands in a text file called install-mypackage.command:

#!/bin/bash

/usr/bin/curl https://www.example.com/mypackage.pkg > /tmp/mypackage.pkg
/usr/sbin/installer -pkg /tmp/mypackage.pkg -target /
/bin/rm /tmp/mypackage.pkg

When the .command file is opened by the user, the package will be downloaded and installed.

This approach assumes:

  • The software is distributed as a flat .pkg file.
  • You can host the package somewhere privately.

Using sftp instead of curl

If your files are hosted on a Secure File Transfer Protocol (sftp) server, use the sftp client. To script the client, use a batch file or follow answers to Single Line sftp from Terminal.

Improvements

Please note this script has no error checking. Consider this script a starting point for your own script.

You could add a password to your web site and then use a URL with the credentials embedded, such as https://username:password@www.example.com/mypackage.pkg.

Given you have ssh access to the computers, you could run this script or commands remotely.

4
  • Thank you @Graham. I was also trying this way as I can't see an easy of running the file from FTP directly. I am giving a try to this idea and assuming this is the best solution at the moment. – Udhy Aug 12 '19 at 12:02
  • 1
    A pkg itself can download contents from a URL but that is not trivial to create and may now be deprecated. Also installing directly from FTP is not supported by Apple's tools. – Graham Miln Aug 12 '19 at 12:06
  • I am trying this. But I have sftp location from where I want to download as you instructed. /usr/bin/curl sftp://username:password@sftp1.mycompany.com/mypackage.pkg > /tmp/mypackage.pkg It says Protocol SFTP not supported or disabled in libcurl And after that, I have tried to enable with: brew install curl --with-libssh2 its says invalid option: --with-libssh2 Any suggestion ? – Udhy Aug 12 '19 at 16:01
  • I have updated the answer to mention the sftp client on macOS. For ftp fetches use, sftp instead of curl. – Graham Miln Aug 12 '19 at 17:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .