Re: Problem with small script

2016-02-18 Thread Robert Parker
On Fri, Feb 19, 2016 at 12:45 AM, Greg Wooledge wrote: > On Thu, Feb 18, 2016 at 05:58:28PM +0100, baldu...@units.it wrote: > > > On Thu, Feb 18, 2016 at 11:06:37PM +0700, Robert Parker wrote: > > > > The script: > > > > #/bin/bash > > ^ missing !

Re: Problem with small script

2016-02-18 Thread Robert Parker
On Thu, Feb 18, 2016 at 11:30 PM, Greg Wooledge wrote: > On Thu, Feb 18, 2016 at 11:06:37PM +0700, Robert Parker wrote: > > The script: > > #/bin/bash > > # testlink.sh > > # must be run as root > > > > file1="$1" > > shift > > mandi

Problem with small script

2016-02-18 Thread Robert Parker
The script: #/bin/bash # testlink.sh # must be run as root file1="$1" shift mandir=/usr/local/share/man/man3/ cp "$file1" "$mandir" cd "$mandir" echo '$hash = '"$#" while (( "$#" )); do file2="$1" ln "$file1" "$file2" shift done Results: >> sudo ./testlink.sh readfile.3 readtextfile.3

Re: Why does a Bash shell script write prompts followed by reads and do it right?

2015-09-02 Thread Robert Parker
r variable default value: 0 Begining with an assignment operator, enter C code for this option: = 1 So getans() is the origin of the problem. I have spent quite some time rewriting that and in the above it is the cleanest version I've written but it has clearly caused problems down the track.

Re: Why does a Bash shell script write prompts followed by reads and do it right?

2015-09-01 Thread Robert Parker
On Tue, Sep 1, 2015 at 12:34 AM, John McKown wrote: > Not a bug, so likely the wrong forum. > > Have you tried doing a fflush() after the fputs()? I.e. something to tell > the Kernel to "write this out immediately!". In the case of write(), I > think you need to use the O_SYNC flag in the open()

Why does a Bash shell script write prompts followed by reads and do it right?

2015-08-31 Thread Robert Parker
A trivial script example that just works: #!/bin/bash # echo a prompt and write the user's response to a file. echo "Enter variable name: " read ans echo "$ans" > tmpfil echo "Enter variable type: " read ans echo "$ans" >> tmpfil echo "Enter variable default value: " read ans echo "$ans" >> tmpfi