How to enter a password in script [SOLVED]


Recommended Posts

i'm setting up an rsync script, where the first command prompt's a request for the destination source's password. Ideally the script would enter the password for the rsync to run. but how exactly do i write that into the script (or is there another way?) i have no problem running this in terminal manually where i can type the password in, it looks like this:

rsync -avhP --progress /source/file/path [email protected]:/destination/file/path
[email protected]'s password: 

so writing the script, what should the entry to fill the password look like here?

#!/bin/bash

echo "Starting File Server Backup"
echo "This May Take a While"

#Backup and Sync local file server
rsync -avhP --progress /source/file/path [email protected]:/destination/file/path
[email protected]'s password: <-- what should i enter on this line?

 

Edited by Cpt. Chaz
Link to comment
3 minutes ago, JoeUnraidUser said:

Try adding "<<<password" to the end of the command:


rsync -avhP --progress /source/file/path root@192.168.1.X:/destination/file/path <<<password

Change "password" to your password.

No dice. i've also tried variations of read and echo | sudo from write-ups in other forums with no luck either.

 

i've also read warnings of putting passwords in scripts, but all i'm dealing with here are two of my personal private networks over vpn. no exposure from the inside or outside, so i'm not worried about it from a security standpoint. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.