Would like to "echo" a line, "read" reply, then execute the reply: How in bash?
Apologies. I've been out of Unix for 14 years, and the gears have rusted. Also, Unix has changed - enough similarities to memory that I'm pretty comfy though.
Glad to see lots of info available via google. However changes are going to take getting used to. Have set up a testbed of 3 nearly identical machines, hoping to make an (at home) private network where I can automate installs and set-ups using NIS and NFS (Similar to work I once did). Have found useful scripts interspersed with comments, would like to copy and paste them to a bash script that: Reads the line. Echos the line. Reads the reply. Executes what is typed. Essentially, by making myself type (or copy & paste) the commands I think I'll become familiar. Figured I'd use a spreadsheet, select the file, and paste into column B of the spreadsheet. In column A I'd paste: echo " and in column C I'd paste: " Then I'd cut and paste into a text document, insert the lines: read A $A behind every command necessary to the actual task. Figured I'd have to escape the ' and ". Ran a test (test.bash): #!/bin/bash for i in `seq 1 10`; do echo "Enter a command:" read A echo "Trying $A" $A done works fine when I type ls -alg but not so when I type ls -alg | grep dwrx so I'm wondering if someone has a suggestion? Thanks for any ideas. |
try using
Code:
... |
There is a typo. It should be eval instead of evaal.
|
Try adding a new 2nd line
Code:
#!/bin/bash |
Quote:
|
|
Thanks! eval (oh yeah! I remember that now!) does the trick. Also thanks for the set -xv, which will be useful when the scripts have been modified to fit my situation. Appreciate it!
|
All times are GMT -5. The time now is 04:03 AM. |