Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Questions about a simple shell script (reading options)
Post Body

I'm new to shell scripting (very new): this is my first effort!

I'm trying to write a script that logs into server, gives it a password, then moves files via scp. I have this:

sshpass -p $PASSW scp [scp-opts] $FILE $LOGIN@servername:$DEST

where $FILE and $DEST are command line args, and $PASSW and $LOGIN are defined in .bashrc.

I know how to read arguments off the command line, but I want to be able to pass '-r' to scp, so I can transfer directories. I've been told that getopts handles options, but since I only want to use '-r', and nothing else, is there a good way to avoid using getopts?

Also, $PASSW is the password, in plain text. It's defined in my .bashrc. Is there a safer way to store it, and still use it as an argument to scp?

If there's a better place to post (a LearnShell reddit) let me know and I'll ask them.

Thanks!

Author
Account Strength
90%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,219
Link Karma
39
Comment Karma
1,180
Profile updated: 10 hours ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago