I need to transfer a text file to a remote PC (freeSSH) using SFTP and SSH from a Mac host. These two are connected in a local network.
So is there a way to run an SFTP command (with the username and password provided) from inside the Bash script?
I already tried some scripting with expect, but I didn't get any results.
I found a similar post, How to run the sftp command with a password from a Bash script, but it is for Linux. I have a Mac.
You can download and install sshpass on Mac as well. Get the latest version source from this download link
Rest of the steps on using sshpass are there in the linked answer of mine.
lftp is great for scripting ftp (and sftp, ftps). And you can install it with brew:
brew install lftp
And for installing the latest version of sshpass using homebrew:
brew install https://raw.githubusercontent.com/EasyG0ing1/sshpassBrew/main/Formula/sshpass.rb
You might have to do this to install it:
wget https://raw.githubusercontent.com/EasyG0ing1/sshpassBrew/main/Formula/sshpass.rb
brew install sshpass.rb
Although #anubhava's answer is correct, it points to the sources only and compiling it without help is hard.
To install sshpass on MacOS using brew easily please use this unofficial package:
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
Source: https://gist.github.com/arunoda/7790979
Related
My mac is having MacOS 10.12.4 (Sierra). And I have installed homebrew using command line. This is what look like when I run "brew config" command.
Then I wanted to install class-dump using following command.
"brew install class-dump". But when it gives me following error. Can some one tell me the reason and what should I do?
I was able to solve the problem by installing class-dump manually without using home brew. I downloaded the class-dump in using this link. Then copy the class-dump file to the following location "/usr/local/bin". Then all works fine
Here is a one liner for the lazy people if you already have wget:
$ wget -qO- http://stevenygard.com/download/class-dump-3.5.tar.gz | tar xvz - -C /usr/local/bin
In the packages window of CygWin, when I type sshpass, nothing comes up. I tried installing similar packages like openssh etc hoping one of them contains sshpass but no luck.
sshpass is not available as Cygwin package. This means that you need to build and install from source. To build sshpass on Windows (Cygwin):
$ curl -LO http://downloads.sourceforge.net/sshpass/sshpass-1.06.tar.gz
$ md5sum sshpass-1.06.tar.gz
f59695e3b9761fb51be7d795819421f9
Build and install to /usr/local/bin:
$ tar xvf sshpass-1.06.tar.gz
$ cd sshpass-1.06
$ ./configure
$ make
$ sudo make install
Which installs two files
the executable /usr/local/bin/sshpass
man page /usr/local/share/man/man1/sshpass.1
Your Cygwin install needs to have the required tools: curl to download, tar to extract, and autoconf, make and gcc to build. I'll assume reader familiarity with installing packages on Cygwin.
sshpass is not available as cygwin package. This means that you need to build and install from source.
See for reference on existing alternative
https://www.cygwin.com/ml/cygwin/2015-02/msg00042.html
This does not directly answer the question "How to install sshpass on Windows?", but can be much easier solution if you need to automatically enter the password when ssh-ing to a machine on Windows system, you can use Plink (part of PuTTY).
plink your_username#yourhost -pw your_password
Window 10 comes with Linux subsystem, you can install a favor of Linux through Windows Store. Then all Linux commands comes easily. sshpass can be easily installed in the subsystem. WSL(Windwos Subsystem for Linux) is the future.
I am writing script to run SU commands programmatically to do various operations. But, All the commands created through my program is not working. Then, i tried those commands in Terminal (Mac os x) by typing it, but it gives the following result,
sudo: apt-get: command not found
Could someone please advise me, why is this error coming up, how can i make these working?
Homebrew installs the stuff you need that Apple didn’t.
install ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
e.g :
$ brew install wget
There's also MacPorts, and fink -- I also have homebrew, but also keep the others around for when I encounter things that one system has that the other doesn't.
apt-get is unique to the Debian based operating systems. If you want a package manager for OSX, may I suggest homebrew
http://brew.sh
I'm trying to get a dump of my local database and it seems I should be using:
mongodump --host localhost:3002
However, the terminal then tells me:
-bash: mongodump: command not found
Am I missing something? Or going about this the wrong way? I'm using it on Mac from the terminal.
I installed mongo (I think) using the following commands:
curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.5.tgz > mongodb.tgz
tar -zxvf mongodb.tgz
As of MongoDB 4.4 (released July 30, 2020), you may need to install mongodump separately because the MongoDB Database Tools (which comprises mongodump, mongorestore, and more) has become its own project.
I found this out because I upgraded to MongoDB 4.4 today and mongodump stopped working.
$ mongodump
zsh: command not found: mongodump
I'm on macOS and installed MongoDB via Homebrew. To get mongodump and friends back, I installed the MongoDB Database Tools via Homebrew:
brew tap mongodb/brew
brew install mongodb-database-tools
If you're on a different OS, this should help:
MongoDB Database Tools Installation
brew tap mongodb/brew; brew install mongodb-community
will also install mongodump.
If you don't have the brew command, you really should consider install Homebrew
If you just extracted the .tgz file, the mongodump command is not available in your PATH. Go to your /bin/ subdirectory inside the directory where you have extracted mongodb.tgz, the mongodump binary should be there. Now you can execute:
./mongodump --host localhost:3002
It's much better though to install MongoDB with a package manager. Read this page:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
and use, for example, Homebrew to install MongoDB and have all the necessary binaries in PATH.
brew tap mongodb/brew
brew install mongodb-database-tools
For using mongodump, mongo-tools library has to be installed from os package manager.
It's probably just not in your path, it should be in the same directory as your "mongod", and you can then run it with:
/path/to/bin/mongodump --host localhost:3002
It's in the official MongoDB docs now. For example, to install the 3.2 version:
brew tap mongodb/brew
brew install mongodb-community#3.2
Then follow the steps to update your PATH environment variable.
You have to install mongo-tools to have mongodump.
sudo apt-get install mongo-tools
For Windows Users
You can download the MongoDB Database Tools from here
And you can read the installation guide here
I am trying to upload my app on Cydia and it requires .deb package. I am unable to figure out how to make .deb packages on mac. I am using 10.6.3 when I write this command on terminal
dpkg-deb -b MyProgram
Terminal output is
-bash: dpkg-deb: command not found
I've install fink, Mac ports insert Mac DVD to find out but nothing helps.
It's available on Homebrew:
brew install dpkg
If you don't have Homebrew installed, go to brew.sh. It's a simple one-liner to install.
Homebrew is less invasive, less complicated, and more popular than Macports or similar.
I installed mac ports 1.7 through terminal as no package is available.
After that I installed Mac ports 1.9 through installer.
Then goto this path /opt/local/bin and run sudo port selfupdate
after that execute sudo port install dpkg
it will take some time and after that your dpkg is successfully configured.
Run this command sudo dpkg-deb -b MyProgram to make MyProgram.deb
Note MyProgram should contain DEBIAN folder and under that control file remove txt extention
Below is control file
Website: www.zeeshanullah.com
Maintainer: zeeshanullah <zzeeshann#gmail.com>
Name: Snapture
Package: zeeshanullah
Section: zeeshanullah
Version: 2.x.x
Architecture: iphoneos-arm
Description: GPS joke.
Sponsor: zeeshanullah.com <zeeshanullah>
dont forget to place a new line at the end of control file otherwise you will get an error.
You need Xcode installed on your system before using mac ports - you find it on the second mac DVD, I think. After that, you can install mac ports and then via the Terminal type "sudo port install dpkg", press return and enter your password. It may take some time to compile. You tried that?
Best option is to use FPM and you can create it in 50 secs:
fpm
i think these links can be useful for you:
How to make a deb on mac
Using ant to create deb