LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   expect/bash (http://www.linuxquestions.org/questions/programming-9/expect-bash-74615/)

sk8guitar 07-21-2003 02:52 PM

expect/bash
 
ok, so i posted a thread a whiel ago about downloading files from remote systems and someone recomended wget (which by the way, rocks). however the system i am doing this on (the server at work) doesn't have wget on it, and they have thse scripts written in expect to connect to ftp shits.

no big deal.

my question is this: does anyone know how to embed expect scripts in a bash script? or how can i find the date in expect. i ask this because the file thats going to be downloaded is named paritally by its date, and that of course changes, so if i don't want to edit this thing every month i need a way for it to be smart enough to know what its doing. any ideas?

sk8guitar 07-21-2003 02:54 PM

id also like to mentoin that i know jack shit of expect.

david_ross 07-21-2003 04:01 PM

Just create 2 scripts 1 bash and one expect the bash script can then be something like this:
Code:

#!/bin/bash
DATE=`date`
/path/to/my/expect_script $DATE

Then the expect script:
Code:

#!/usr/bin/expect
send_user "$argv"

You can ofcourse just use:
Code:

#!/usr/bin/expect
send_user "[exec date]"


Hko 07-21-2003 05:45 PM

Re: expect/bash
 
Quote:

Originally posted by sk8guitar
my question is this: does anyone know how to embed expect scripts in a bash script?
Do you mean you want just one file? Like the expect script inside the bash script? Then make expect read its script from stdin, and use a here-document. Something like:
Code:

#!/bin/bash
# Bash commands go here

/usr/bin/expect - << EndMark
This is the expect script (dont know how they like)
expect commands go here
and here
until:
EndMark

# More bash commands go here.

exit 0


sk8guitar 07-23-2003 01:20 PM

awesome guys, thanks!

Photar 10-06-2009 01:00 PM

Quote:

Originally Posted by sk8guitar (Post 385846)
ok, so i posted a thread a whiel ago about downloading files from remote systems and someone recomended wget (which by the way, rocks). however the system i am doing this on (the server at work) doesn't have wget on it, and they have thse scripts written in expect to connect to ftp shits.

no big deal.

my question is this: does anyone know how to embed expect scripts in a bash script? or how can i find the date in expect. i ask this because the file thats going to be downloaded is named paritally by its date, and that of course changes, so if i don't want to edit this thing every month i need a way for it to be smart enough to know what its doing. any ideas?

This works for me:

spawn mysqldump --opt --flush-logs --user=root InfoCentre --result-file=/backup/sqlbackup[exec date "+%Y-%m-%d:%H:%M:%S"].sql -p


All times are GMT -5. The time now is 02:47 PM.