Problem in making a script
Amrit Pal Pathak
amritpalpathak1 at gmail.com
Sat Jul 2 09:19:34 UTC 2011
On Sat, Jul 2, 2011 at 5:07 AM, Nils Kassube <kassube at gmx.net> wrote:
> Amrit Pal Pathak wrote:
> > Till now what i have did =>user will also enter the that part of the
> > line which is not needed to change in original file.
> > suppose in orignal file line 9 holds:
> > device = /dev/ttyACM0
> > So in scripting i have use echo command as:
> > > echo "Please enter your port address in a format => device =
> > > /dev/your-port-address "
> > What i think it is not right choice.He should enter only
> > "ttyACM0" .Till now we are replacing the whole line .So how we can
> > achieve it ?
> You could extend the echo command with the rest of the text you need in
> the line. Something like this:
> echo -n "Please enter device name: "
> read device
> echo "device = /dev/$device" >> "$TEMP"
> Here $TEMP is temporaily file name?
Can I use here a variable then can replace $fname with
that variable in following code.
sudo wget http://22.214.171.124/~amritpal/edit/kannel.conf
sudo chmod a+w kannel.conf
echo -n "Please enter device name: "
echo "device = /dev/$device" >> "$TEMP"
head -n $((29 - 1)) "kannel.conf" > "$TEMP"
echo "$fname" >> "$TEMP"
LEN=$(cat "kannel.conf"|wc -l)
tail -n $(($LEN - 29)) "kannel.conf" >> "$TEMP"
mv "$TEMP" "kannel.conf"
> However I would really suggest you learn bash scripting with the help of
> one of the manuals I mentioned in a previous mail. Or as an alternative
> I can recommend the O'Reilly book "Learning the bash shell" by
> Cameron Newham & Bill Rosenblatt.
Ok i will read it now.Thanks.
> Yes, that takes time but that way you
> know what you are doing and you don't have to ask for every tiny detail
> and then hope for a useful answer.
> Thanks again.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ubuntu-users