Skip to content
Advertisement

How to convert this powershell script to bin/sh script?

How to convert this script:

JavaScript

or with parameter:

JavaScript

How to make similar script that works in linux /bin/sh? I want to copy files to some network location (windows shared folder). There is no scp on windows server and i cannot install anything.

Advertisement

Answer

On Linux, you’ll need the following (verified on Ubuntu 18.04, albeit not with a Windows domain account):

  • Prerequisite: The cifsutil package must be installed, which the script below ensures (it calls sudo apt-get install cifs-utils on demand).

  • Choose a (temporary) mount point (a local directory through which the share’s files will be accessible).

  • Use the mount.cifs utility to mount your share, and umount to unmount (remove) it later.

  • Use cp -R to copy a directory hierarchy.

Note:

  • sudo (administrative) privileges are required; the script will prompt once for a password, which is normally cached for a few minutes.
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement