简体   繁体   中英

Configuring s3cmd non-interactively through bash script

I am trying to configure s3cmd. When at the command line,

s3cmd --configure 

runs the wizard and the data entry is straight forward. Now, I want to run this through a bash script. I used:

s3cmd --configure --access_key=XXXXXXX --secret_key=XXXXXX -s --no-encrypt 

and the interactive wizard still pops out asking me the params I just supplied. I then tried dumping out the contents of the config file (.s3cfg) and writing it to a file in the root hoping s3cmd would read it:

s3cmd --configure --access_key=XXXXXXX --secret_key=XXXXXX -s --no-encrypt 
--dump-config 2>&1 | tee .s3cfg

but that didn't work either.. Any ideas? Thanks.

--configure is an interactive mode to define all settings so as soon as you turn this option it will bring the interactive questions mode.

If you want to script the configuration of the tool, I think you should directly edit the .s3cfg (for mac/linux) or s3cmd.ini (for windows) in your user home directory and set the values you want to set.

Alternatively you can dump the current settings (as you made with --dump-config ) make change and save using s3cmd --config=<new_file>

At least with version 1.1.0-beta3 , this worked well for me:

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...

echo -e "${AWS_ACCESS_KEY_ID?}\n${AWS_SECRET_ACCESS_KEY?}\n\n\n\n\nY\ny\n" | \
  s3cmd --configure

I'd recommend doing it once manually to figure out the exact succession of input strings required, and then adapting the echo command accordingly (you have the option not to save the config file in the interactive mode).

Hope this helps someone!

Simply removing the --configure option will do the trick. The authors command was allmost correct

s3cmd --access_key=XXXXXXX --secret_key=XXXXXX -s --no-encrypt 
--dump-config 2>&1 | tee .s3cfg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM