Re: [vox-tech] newbie annoyed with tin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] newbie annoyed with tin
On Thu, 30 Jan 2003, Katie wrote:
> OK, here's what I've got:
> qy | lynx "https://secureweb.ucdavis.edu:443/cgi-auth/sendback?"\
> -force_secure -accept_all_cookies -auth="login:password" > /dev/null
> When I enter the file name at the command line I get this message:
> /home/katie/bin/runtin: line 3: qy: command not found
> and I'm back to the command line. How do I fix this?
qy is not a command. However it looks like those are responses to the
prompts lynx is about to offer, so you need to feed them through the pipe
("|") ... echo will do that.... echo sends its arguments to stdout. You
had it in there before.
Your questions suggest that you need a little boost in shell concepts, so
here are some experiments for you to try interactively to get a "feel" for
what is happening here so you avoid the "magic incantation" habit. :)
These may seem like excessively simple examples, but each one touches on
as few concepts as possible so you can be sure not to miss anything.
A very fundamental command you should know is "echo". You use it like:
$ echo "hello world"
where the quotes hold the two words together as one unit. You can omit
$ echo foo
if you aren't trying to send specific spaces to the screen. If you don't
mind losing extra spaces, you can do
$ echo hello world
because the shell breaks up the pieces before it gives them to the command
(or any program or script). By default, the echo command takes each of
these pieces and prints them out with a single space between them. If you
want to continue your commandline on the next line, you can use the "\"
(as described before):
$ echo hello \
as long as "\" is the last character on the line.
You can also have echo print out more than one line if you tell it to look
for "\n" to mean "newline" with the "-e" option:
$ echo -e "one\ntwo\nthree"
Just as an example of a command that does something with input, consider
the sort command. Type
at which it stops and waits... so keep typing some words on separate
and then press Ctrl-D to signify the end of input ("end of file"). It
should print out:
and leave you at the command line.
With pipes (the vertical bar symbol "|"), you can take the output of one
command and feed it directly to the next:
$ echo -e "pear\napple\npeach" | sort
Now, lynx is an interactive text-based web browser... try
$ lynx www.google.com
and it launches an interactive session that spits information on your
screen, and waits for keypresses to determine what to do next. On my
system, first thing I get is whether I want to allow a cookie, and I press
the "n" key. Then I want to quit, and I press the "q" key. Then it asks
me if I _really_ want to quit, and I press the "y" key. So, to avoid
$ echo nqy | lynx www.google.com
and it does the typing for me.
In the case of activating your kerberos password, the screen activity is
not needed, so we can dump the output into the bit bucket:
$ echo nqy | lynx www.google.com >/dev/null
using the ">" operator to redirect all output to the file "/dev/null"
which is a special file that forgets what you put into it. In this case,
google has been visited, but you haven't been bothered to do it
For completeness of the discussion, you could put the keypresses into a
$ echo nqy >mykeypressfile
and now you can obtain a similar result with
$ lynx www.google.com <mykeypressfile >/dev/null
A shell script operates much like this ... invoking the shell script
amounts to running another copy of the shell that doesn't look at your
keyboard for input, but rather reads commands from the shell script file.
The difference is that while the shell commands are coming from a file,
the keyboard input is still available to the commands in your script file.
(In the interactive examples, you alternated putting commands in with
supplying input to commands like "sort" and "lynx".) Thus, the
construction of a shell script consists of commands and syntax that you
can use at the command line. (There are shell constructs like "if ... fi"
(if then) that you are not likely to use interactively, but you _can_ if
you want to.)
So, the short story is ... you need to remember to prepend "echo " right
before the "qy" in your script file.
Have fun scripting!
> --- Samuel Merritt <email@example.com> wrote:
> > > > #!bin/bash
> > In addition to Bill's remarks below, this line needs to be
> > #!/bin/bash
> > That is, an absolute path (starts with slash) rather than a relative
> > one.
> --- Bill Kendrick wrote:
> > > Oops - Yes, indeed. The ";"s tell the shell that the next thing is
> > > another command.
> > > What I think you want are "\" (back-slashes), which tell the shell
> > > 'the stuff on the following line should be considered to be part of
> > > this one single command (or set of commands)'.
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> vox-tech mailing list
Jeff Newmiller The ..... ..... Go Live...
DCN:<firstname.lastname@example.org> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...2k
vox-tech mailing list