How to put a string in the command line ?

How to put a string in the command line ?

Post by Jens Schleusen » Thu, 13 Nov 1997 04:00:00



I want to write a shell script that - after some internal processing - should
offer me a proposed command in the command line. Principally I want just type
<ENTER> but I want also to be able to do some corrections via command line
editing (ksh, zsh, bash). Is there a corresponding command as simple as an "echo"?
Or must I use complex tools as for e.g. "expect"?

Jens

--
Dr. Jens Schleusener (WT-DV)    DLR (German Aerospace Center)
phone: +49 (551) 709-2493       Bunsenstr.10
fax:   +49 (551) 709-2169       D-37073 Goettingen

 
 
 

How to put a string in the command line ?

Post by James R. Mart » Sat, 15 Nov 1997 04:00:00


: I want to write a shell script that - after some internal processing - should
: offer me a proposed command in the command line. Principally I want just type
: <ENTER> but I want also to be able to do some corrections via command line
: editing (ksh, zsh, bash). Is there a corresponding command as
: simple as an "echo"? Or must I use complex tools as for e.g. "expect"?

You do not describe well enough the particular application you will
to specifically solve for me to confidently recommend one of several
pseudo-terminal command-line editting front-ends that are freely
available. Is the below to your liking?

ftp.uu.net/archive/comp.sources.unix/volume16/fep/*:
fep/part[01-05]         Front end editor program
ftp.uu.net/archive/comp.sources.unix/volume19/atty/*:
atty/part[01-04]        A command-line editor (for BSD)

There are also C libraries which can do such things, but I would
simply write my own command-line front-end (that is, if you _did_
read the ksh man pages concerning ksh very powerful builtin
command-line re-editting features!)

set -o vi
HISTFILE=.mycommands
while IFS= read -r
do      read -rs
        # (do your command-line processing stuff here...)
        print -s "REPLY"
        eval "$REPLY"
done

If I am not mistaken (my ISP uses a system supporting only pdksh, not
actual kornshell, so this is from memory) the act of reading in input
will enable potential history substitution (type an ESCAPE, then "k"
to find out if this is implemented on your ksh.)

--
james martin


 
 
 

1. Put file lines in an array: how keep line blanks in the string?

Hi,
The pb is that if file 'myFile.txt' contains:

If I do "set -A fileArray `cat myFile.txt`", I'll get:
with the following commands:

But of course I'd like to retrieve EACH line for a single
call to the "echo" command corresponding to a given line
number (minus one)...

Do you know how I could store each string in each cell
of my array (for ex. "here's line 1" in $fileArray[0]) ?

Thanks a lot !

Regards,
Seb

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Apache authorization and CGIs (bug?)

3. put a string to the beginnig of every line...

4. afterstep files missing

5. Find a string, delete that line, delete 1 line before it and all lines after it...

6. LOCALE problems in term

7. remsh script - putting output of more than one command / variable on one line

8. Strange problem with ATI Rage 128

9. Using NCFTP to PUT files at command line???

10. ftp "put" from command line

11. Where to put "pppd" command line?

12. Can I put a ^M on a command line somehow?

13. how to get the full command line string