LinuxQuestions.org
Register a domain and help support LQ
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 11-19-2004, 10:31 AM   #1
sio
Member
 
Registered: Jul 2003
Location: Louisiana, US
Distribution: Slackware
Posts: 129

Rep: Reputation: 15
Simple Bash Question


Im not sure what terms I should search for (which is making this painfully slow to find) but this is all i want to do.

Say I want to use ncftp (this is a generalization)

and the first line of the script issues a

ncftp ftp://me#here.com:mypass@here.com

and then the second and third lines say

put allsys
exit

but after it makes the initial connection it of course doesn't execute the next line, im simply in the ncftp prompt and its waiting for input from me. And of course after i exit ncftp the script continues but thats not very useful.

If anyone could direct me to the chapter this is discussed in-in the ABSG or provide an answer i would appreciate the time.
 
Old 11-19-2004, 10:36 AM   #2
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
does this help:

http://www.aplawrence.com/SCOFAQ/FAQ...c6autoftp.html

??
 
Old 11-19-2004, 10:39 AM   #3
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
or this:
Code:
ncftpput -u login -p password domain.com /remote/path allsys
 
Old 11-19-2004, 12:00 PM   #4
sio
Member
 
Registered: Jul 2003
Location: Louisiana, US
Distribution: Slackware
Posts: 129

Original Poster
Rep: Reputation: 15
well yes those things will let me do a one liner or create a script file specific to the ftp command, but the ftp example was just a generalization.

I'll try and generalize more,

You execute a program, any console program, from the first line in your bash script. The program stops to ask the user for input. I want the bash script to enter the users input automatically which is taken from the second line, so on and so forth.

In the thought of trying to explain this better i thought of some better search terms. automate user input
 
Old 11-20-2004, 12:59 AM   #5
dustu76
Member
 
Registered: Sep 2004
Distribution: OpenSuSe
Posts: 153

Rep: Reputation: 30
The kind of thing you are asking for can be largely done by "here document" in bash.

Say you have a program "prog" where you have to enter id, name and date of birth (say). E.g. "1", "joe smith", "01-01-1970"

Then you do:

Code:
prog <<END
1
joe smith
01-01-1970
END
"END" is just a single word (no spaces, tabs etc. allowed).

Read the bash documentation for more details.

HTH.
 
Old 11-20-2004, 01:28 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally posted by sio
well yes those things will let me do a one liner or create a script file specific to the ftp command, but the ftp example was just a generalization.

I'll try and generalize more,

You execute a program, any console program, from the first line in your bash script. The program stops to ask the user for input. I want the bash script to enter the users input automatically which is taken from the second line, so on and so forth.

In the thought of trying to explain this better i thought of some better search terms. automate user input
If you know for SURE that the requested input will always
be the same you can indeed do something like
echo "username
password
time to live" | my_interactive_command

If you want to be able to do some sort of
sanity checks look at "man expect" ...


Cheers,
Tink
 
Old 11-22-2004, 10:56 AM   #7
sio
Member
 
Registered: Jul 2003
Location: Louisiana, US
Distribution: Slackware
Posts: 129

Original Poster
Rep: Reputation: 15
Ah thanks for the tips, I'll look into those various items.
 
  


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
Very simple BASH scripting question clickster Linux - Newbie 6 11-23-2005 05:28 PM
very simple bash programming question!? Thinking Programming 7 06-01-2005 12:07 PM
simple bash script question bullium Programming 3 11-01-2004 03:42 PM
Bash Scripting--Simple Question mooreted Linux - General 4 05-10-2004 02:44 PM
Simple bash question pk21 Programming 2 12-01-2002 06:06 PM


All times are GMT -5. The time now is 08:19 AM.

Main Menu
Advertisement
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