LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 09-23-2003, 02:11 PM   #1
daeojkim
LQ Newbie
 
Registered: Sep 2003
Posts: 5

Rep: Reputation: 0
Question script help


Hello,

I am trying to write a linux script that would launch a program then the program itself has its own command prompt. Once the program starts I need to issue some commands in the program's prompt to get the program running.

My main question is, is it possible to write a script that will start the program, then input specific commands for that program?

I need to do this repeatedly, start program, load data set, run many commands then quit, restart program then load new dataset and so on. A real pain and very time consuming.

Thanks in advance
 
Old 09-23-2003, 02:31 PM   #2
jpbarto
Senior Member
 
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
it's possible. When your new program starts up it will connect itself to an input device in /dev (probably something like /dev/ttyS2) etc. You're script can then open that device and begin writing to it like a file.

however, are you sure that the app your starting cannot recieve stuff through piping? (this would be way easier).

ie ... when I execute 'ls | grep jason | less' the system automatically feeds the output of 'ls' into 'grep' and feeds the output of 'grep' into 'less'.

jpbarto
 
Old 09-23-2003, 02:48 PM   #3
daeojkim
LQ Newbie
 
Registered: Sep 2003
Posts: 5

Original Poster
Rep: Reputation: 0
I am so dumb

Hi you suggestion was a great help.

did not realize that I could use piping for this program. but I guess you can use piping for almost any program.

This will speed up things a lot. I can just make the script, let it run before I go home and by the time I come back it should be all done!!

Thanks so much!!
 
Old 09-23-2003, 03:01 PM   #4
jpbarto
Senior Member
 
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
not a problem ... and if you are unfamiliar with piping you may find it very useful to find a 'bash scripting' howto out there ... there are MANY very handy tools available to you that can probably help you in many other areas as well.

most how-tos can be found at The Linux Documentation Project (www.tldp.org)

glad to be of help,
jpbarto
 
Old 09-23-2003, 03:01 PM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
If you can not do this using pipes, as jpbarto suggested, because the program is interactive, then there's the "expect" utility. With this you can program input for interactive programs.
See "man expect" from more info.
 
  


Reply



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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:27 PM.

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
Open Source Consulting | Domain Registration