chat Utility

Posted on 1999-12-07
Medium Priority
Last Modified: 2013-12-15
I am seeking a general utility that can communicate from a batch script with an interactive program such as smbclient. I want to invoke the shell script and have no further interaction.  Is chat the program?  Is another better?  Where can I find it? I'm running RedHat 6.5, Mandrake
Question by:RonJD
  • 2

Expert Comment

ID: 2264778
For smbclient, use the -c option and seperate your commands with a semicolon. This works very well.

Author Comment

ID: 2265324
This answer solves my immediate problem--thanks!  
But my question was more general.  Is is the norm in Linux for applications to have command-line options that can be operated in batch mode. If not, is there a keystroke emulation program out there that can automatically interact with programs that require a dialog with the user?

Author Comment

ID: 2265343
Adjusted points to 75

Accepted Solution

crouchet earned 280 total points
ID: 2265629
The answer is -- sometimes.

Many Linux programs and utilities do have command line options that will eliminate the need for interaction. To find out for a specific program, go to the command line and type:

man YOURCOMMAND <enter>

so if you wanted to find out about smbclient you would type:

man smbclient

Some also give you "useage" information. Type:

smbclient -?
smbclient -help
smbclient --help

If there is no command line option then you may be able to redirect the input of your responses from a second script, like this:

smbclient < myscript

Where myscript is a file with the responses you want to send. WHether this works is according to whether (and how) the program accepts it's input from standard in (stdin). You will probably just have to try it to find out.

Here is another way to redirect the input. This is called a "here document" as it eliminates the need for that second script file by letting you put your commands directly in the script file that contains the command itself.

smbclient << EOF

EOF is not an eof character, but the letters E, O and F. That could be something else like END, but EOF if the standard most programmers will recognize.

Notice that EOF **MUST** be the first and only thing on a line all by itself to terminate the input. The <enter>s at the ends of the lines register just like hitting the enter key during interactive input. This method works reasonably well for many programs, but not all.

Generally, if there is a good reason to run a program from a script one or more of these methods will work. If the author forgot to include such capibility another programmer would add it through the magic of GPL, so by the time you get it the progam should have this capibility.

For more information on input redirection and shell scripts in general I recommend a book called "UNIX Shell Programming" by Stephen G. Kochan & Patrick H. Wood. ISBN 0-672-48448.  You might also find thier book "Exploring the UNIX System" , ISBN 0-672-48447-1 to be useful. I'll warn you that these are oldies, but they are easy to follow with clear examples and good indexes. They are also inexpensive.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension . This reminded me of questions that come up here at EE along the lines of, "How can I tell the type of file from its cont…
Fine Tune your automatic Updates for Ubuntu / Debian
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month6 days, 2 hours left to enroll

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question