Problem in making a script
Amrit Pal Pathak
amritpalpathak1 at gmail.com
Sat Jul 2 14:29:58 UTC 2011
On Sat, Jul 2, 2011 at 7:21 AM, Nils Kassube <kassube at gmx.net> wrote:
> Amrit Pal Pathak wrote:
> > On Sat, Jul 2, 2011 at 5:07 AM, Nils Kassube <kassube at gmx.net> wrote:
> > > 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?
>
> Yes. At the line "..." I omitted the creation of that temp file etc.
> because I wanted to show how to use the echo command with the user input
> appended to the extra text.
>
> > Can I use here a variable then can replace $fname with
> > that variable in following code.
>
> I'm not sure what you want to ask here. Anyway, you can name a variable
> whatever you want. It doesn't matter if it is "fname" or "device" or
> "donaldduck". It is only important that you later use the right variable
> when you write to the conf file. Of course it is much easier to
> understand the code if you use a variable name which tells you something
> about the designated contents. I was using "device" for clarity because
> the user input was a device name. I would expect some file name in a
> variable "fname" but feel free to use "fname" instead of "device".
>
> > sudo wget http://202.164.53.116/~amritpal/edit/kannel.conf
> > sudo chmod a+w kannel.conf
>
> While these lines have nothing to do with your original question, I'll
> comment on them anyway. These lines are a bit strange because first you
> use sudo to wget a file, and then you change the permissions to make the
> file world writeable. If you don't use sudo for the wget command, you
> don't need to change the permissions afterwards.
I think you said reverse.Your meaning might "if you use sudo for wget
a file ,there is no need to change the permissions".
May be i am wrong.
> Never use sudo unless
> you really know it is needed.
>
> > echo -n "Please enter device name: "
> > read device
> > echo "device = /dev/$device" >> "$TEMP"
> Yes you was right.
>
My stupidity.!!!
> Well, that line is in the wrong place. You can't write to a temporary
> file before you create it. If you have used the TEMP variable before,
> you might write to the wrong file. If it wasn't used before, it would
> simply be a syntax error.
>
> > TEMP=$(mktemp)
> > head -n $((29 - 1)) "kannel.conf" > "$TEMP"
> > echo "$fname" >> "$TEMP"
>
> Replace this line with the one that was in the wrong place above.
>
> It worked.
>
Thank you very much Sir
amritpalpathakgne.wordpress.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20110702/12d62952/attachment.html>
More information about the ubuntu-users
mailing list