Thread: Expect and scripting.

Expect and scripting.

From
Eric Naujock
Date:
Does anyone have an example of an expect script that could work. For some reason either I am not understanding something about this or My script is just wrong but my pg_sump script does not work with expect.

I have all my databases password protected hence a need for doing this for backup.

Currently this is what I am doing

spawn /usr/bin/pg_dump -U myusername -b -c -F c -f /backup/databasename_sql databasename
expect Password:
send "the_password\r"

any tips or suggestions would be appreciated.

thanks in advance.

--------------------------------------------------------------------------------
Eric Naujock CCNA, CCDA, A+, Network +, I-Net +
Abacus II
5610 Monroe St.
Sylvania, Ohio 43560
<http://www.abacusii.com>
E-mail - naujocke@abacusii.com
Phone - 419-885-0082 X 241
Fax : 419-885-2717
AOL IM: erlic
Attachment

Re: Expect and scripting.

From
"Guthrie, John"
Date:
Hi, I am doing some postgres stuff with expect right now (not pg_dump... yet).
 
The only differences I see with what I have (which works) are:
1) I use quotes on the expect line (and no colon):
    expect "Password"
2) I finish up with an expect that match the last line I expect back. It seems to me I had to do this to get expect to not just up-and-quit after it had provided all the inputs. It doesn't matter if it really matches anything, except that I get an error message (I can ignore) if I put a bogus value a la:
   expect "This won't show up"
3) Also, you may want to set a large timeout, large enough for the command to finish:
   set timeout 30
 
HTH
John Guthrie
-----Original Message-----
From: Eric Naujock [mailto:naujocke@abacusii.com]
Sent: Sunday, June 23, 2002 9:46 PM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] Expect and scripting.

Does anyone have an example of an expect script that could work. For some reason either I am not understanding something about this or My script is just wrong but my pg_sump script does not work with expect.

I have all my databases password protected hence a need for doing this for backup.

Currently this is what I am doing

spawn /usr/bin/pg_dump -U myusername -b -c -F c -f /backup/databasename_sql databasename
expect Password:
send "the_password\r"

any tips or suggestions would be appreciated.

thanks in advance.

--------------------------------------------------------------------------------
Eric Naujock CCNA, CCDA, A+, Network +, I-Net +
Abacus II
5610 Monroe St.
Sylvania, Ohio 43560
<http://www.abacusii.com>
E-mail - naujocke@abacusii.com
Phone - 419-885-0082 X 241
Fax : 419-885-2717
AOL IM: erlic

Re: Expect and scripting.

From
Josh Berkus
Date:
Eric,

> I have all my databases password protected hence a need for doing this for
backup.
>
> Currently this is what I am doing
>
> spawn /usr/bin/pg_dump -U myusername -b -c -F c -f /backup/databasename_sql
databasename
> expect Password:
> send "the_password\r"
>
> any tips or suggestions would be appreciated.

I would suggest instead configureing pg_hba.conf to allow "Trust" access from
the specific user and host that does the backup.   This will save you a lot
of trouble.

--
-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology     josh@agliodbs.com
    and data management solutions     (415) 565-7293
   for law firms, small businesses      fax 621-2533
    and non-profit organizations.     San Francisco