LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-21-2003, 01:52 PM   #1
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
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?
 
Old 07-21-2003, 01:54 PM   #2
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
id also like to mentoin that i know jack shit of expect.
 
Old 07-21-2003, 03:01 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
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]"
 
Old 07-21-2003, 04:45 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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

Last edited by Hko; 07-22-2003 at 03:35 AM.
 
Old 07-23-2003, 12:20 PM   #5
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
awesome guys, thanks!
 
Old 10-06-2009, 12:00 PM   #6
Photar
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by sk8guitar View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about expect. imjoe Programming 1 10-26-2005 04:42 AM
Expect how to? e-freak Programming 2 09-24-2005 04:49 AM
help with expect neyoung Programming 3 02-09-2004 09:41 PM
How to use expect TomCruise2002 Linux - General 0 10-02-2003 09:53 PM
expect sk8guitar Programming 3 07-29-2003 09:24 PM


All times are GMT -5. The time now is 05:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration