[Nottingham] input to bash

David Wolfson eaxdrw at nottingham.ac.uk
Thu Aug 19 11:18:37 BST 2004


Well, I think the first response to this will be something along the lines of "you should you perl for this", but as I was here trying to do it in bash a 7.30 last night I kinda missed a trick really, didn't I?

Anyway, what's the the point of this?

I am trying to write an interface for a pre-compiled C+ pro that I have not access the code for.  Currently users (of which I have currently become one) manually edit variables in a bash script which edits input images before calling the program in question.  As some of them baulk as the though of a text interface, the concept of editting a program is frankly terrifing to them.  I've rehacked the input script so that it asks them for variable values all on its own, and can run the program sucessfully.  All good.

BUT (there it is!)

the program not only has a number of command line arguments (fine, these can be set in the script), but it also requires the 3 lots of user input later in the processing.  How can I automate this within the script?  So far I've been playing with reading these from a file (example in the restraunt below), but I'd really like to input these values when requested by the program, from script variables.  

I'm still in the process of googling this, but nothing has kept out so far, so hint/tips/links gratefully recieved.

Cheers,

Dave


dave.sh
-----------------------------------------------------------
#!/bin/bash
# DRW 19/8/04
# program to tell the waiter.sh my name

#name=dave

waiter.sh < name.txt


#echo -n "$name"



name.txt
-----------------------------------------------------
dave

waiter.sh
-----------------------------------------------------
#!/bin/bash
# DRW -19/08/04
# program that needs input from the user to test
# pausing and piping to the cmd line

echo "what's you're name?"
read name
echo "hello $name"


This message has been scanned but we cannot guarantee that it and any
attachments are free from viruses or other damaging content: you are
advised to perform your own checks.  Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.




More information about the Nottingham mailing list