Hello Everyone,
I do Django web development on my Mac at home, and then I rsync the files with the Ubuntu web server. I want to write one single bash shell script that rsyncs the files and restarts Apache on the server.
Here is the script I have so far, sync.sh:
#!/bin/bash
echo -n Password:
read -s PW
rsync --compress --times --perms --links --recursive --delete --include-from=incls.txt --exclude "*" /User/bollweevil/django-site/* awesomewebsite4 9.com:websites/scripts
echo $PW | ssh awesomewebsite4 9.com sudo /etc/init.d/apache2 reload
This script works, but it is kind of annoying because it prompts me for the SSH password twice. It prompts me for the SUDO password only once (lines 2 and 3 prompt, line 5 uses it), but it prompts me for the SSH password twice. I tried this:
echo -n SSH Password:
read -s SSH_PW
echo $SSH_PW | rsync ...
But it didn't work, it just prompted me for the SSH password again. It didn't print the $SSH_PW in cleartext to the screen.
How can I make this work? How can I make it prompt me for the SSH password only once? In this script, it saves me a tiny bit of work. In a more complex script, it could save me a huge amount of work.
Also, is this safe? I am never writing down the password in cleartext, but it is the root password for the web server, and it does exist as cleartext inside that variable. That variable would never do something stupid like reveal its contents during a traceback, would it?
Thanks.
3 12069
Hello Everyone,
I wish I could edit my earlier post, but I can't. The earlier post asks how to make a bash script fill in the password when prompted. I found something that does exactly that: expect.
Expect successfully fills in the password, BUT it breaks something else. Here is the new and improved code, in sync.sh: -
#!/bin/bash
-
echo -n Password:
-
read -s PW
-
expect -c 'spawn rsync --verbose --stats --progress --compress --times --perms --links --recursive --delete --include-from=incls.txt --exclude "*" /Users/bollweevil/django-site/* awesomewebsite49.com:websites/scripts' -c 'expect password:' -c 'send '$PW'\n' -c 'expect eof'
-
So, let's invoke ./sync.sh
It almost works. "rsync" gets called, it prompts for a password, then "expect" feeds it a password, and the remote server likes the password and accepts it. rsync starts to display its status. And then... -
building file list ...
-
rsync: link_stat "/Users/bollweevil/django-site/*" failed: No such file or directory (2)
-
0 files to consider
-
What? What's wrong? Let's copy the "rsync ..." line out of the "spawn ..." statement, just a completely direct copy, and then paste it right into the shell: -
new-host: bollweevil$ rsync --verbose --stats --progress --compress --times --perms --links --recursive --delete --include-from=incls.txt --exclude "*" /Users/bollweevil/django-site/* awesomewebsite49.com:websites/scripts
-
building file list ...
-
45 files to consider
-
What?! Why does it work perfectly now? I copied it exactly! Clearly, "expect" or "spawn" is doing crazy crap and messing things up.
Please help.
Thanks.
gpraghuram 1,275
Recognized Expert Top Contributor
Try to use expect so it wont ask the password again.
Thanks
raghu
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: |-|erc |
last post by:
Hi!
Small challenge for you.
The index.php uses this file and calls layout(). Take a look at www.chatty.net this file
draws the chat login box on the right. I traced the CHAT button it submits and
goes to the index file again, I can't figure out how it opens the chatroom. I want
to get it to skip the login box and go straight to the room, with user name "guest"
or "" or whatever but I'll add a field to type the name in the chat room....
|
by: Eric Woudenberg |
last post by:
I just installed a Python 2.3.4 Windows binary on a friend's WinXP
machine (because the latest Cygwin-provided Python 2.3 build leaves
out the winsound module for some reason).
When I try and run this newly installed Python from bash it just hangs
(no version message, no prompt, CPU is idle). When I run it from IDLE,
or the DOS CMD prompt, it runs fine. Also, Python scripts using the
new version run fine, even invoked on the bash command...
|
by: Dmitry |
last post by:
Hi folks!
I need to find a way to switch to a different Unix user from within
the Perl script that is currently ran unattended. Script must switch
user in order to execute proper profile for different Data Base
Instance and set corresponding environmental variables correctly.
Script works fine for a single Data Base Instance. I need to be able
to run it consecutively for several others instances. This requires
login in as a different...
|
by: F. Biguet |
last post by:
Hello,
I want to create a generic script that connects to Oracle databases
(from 7.3.4 to 9.2 version) with a guest user. This script should
return 1 if connection is successful and 0 if not.
My problem is due to the 3 requests for password when the connection
fails. I can't find any option that allows to ask for password only
one time.
Has anyone already written a such script?
|
by: Max |
last post by:
Hello all,
I am trying to protect a page within my site with a JS password
scheme.
Now I know JS can be quite easily "circumvented", but I came by a code
below.
My question is:
1. Is there a way to find a password for this script? How easily?
2. Is there a stronger scheme available in JS?
| |
by: Jan Danielsson |
last post by:
Hello all,
How do I make a python script actually a _python_ in unix:ish
environments?
I know about adding:
#!/bin/sh
..as the first row in a shell script, but when I installed python on
a NetBSD system, I didn't get a "python" executable; only a "python2.4"
|
by: jodyblau |
last post by:
I applogize for posting this a second time (I posted in the
access-multiuser group as well), but this group seems to respond more
rapidly, and I have been trying to figure this out for what seems like
forever.
I have the Access 2002 Developer's Handbook, and I am trying to learn
from the example provided in Chapter 2, but I am running into the
following problem.
I set an admin password and a username and password on the backend,
|
by: John Salerno |
last post by:
Hi all. I just installed Ubuntu and I'm learning how to use the bash
shell. Aside from the normal commands you can use, I was wondering if
it's possible to use Python from the terminal instead of the normal bash
commands (e.g. print instead of echo). My main reason for asking is that
I like using Python for everything, and if I don't need to learn the
bash 'language', then I won't just yet.
Thanks.
|
by: lokeshrajoria |
last post by:
Hello Everyone,
Please go through this script code .
this script files executing in bash 2.05 version without mentioning sh. That means if I type simple in command prompt :
$moverds.sh
then it is execution without any problem and when I try to execute by type in command prompt like:
$sh moverds.sh then
its giving the following Error
root@aramco2.temp.com # sh moverds.sh
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |