* standard redirections
@ 2002-05-17 13:22 César Soler
2002-05-17 15:16 ` John Hallam
0 siblings, 1 reply; 3+ messages in thread
From: César Soler @ 2002-05-17 13:22 UTC (permalink / raw)
To: linux-admin
Hi all,
I would like to run an interactive script, but I'm a bit lost.
Is there any way to read a value from the keyboard when the standard
input has been assigned to a file into a sh-script? It means, into a
script I have a while loop, like:
cat $file | while read line;do
[commands]
echo "Continue(y/n)?"
read cont
if [ "$cont" = "n" ];then exit 1;fi
[more commands]
done
In this way, cont is read from $file. Does anybody know how I could
redirect again de standard input?
Thanks in advance for your help!
--
Best regards,
César mailto:csoler@euskalnet.net
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: standard redirections
2002-05-17 13:22 standard redirections César Soler
@ 2002-05-17 15:16 ` John Hallam
2002-05-18 20:19 ` César Soler
0 siblings, 1 reply; 3+ messages in thread
From: John Hallam @ 2002-05-17 15:16 UTC (permalink / raw)
To: César Soler; +Cc: linux-admin
On most UNIX systems /dev/tty is the name for the "controlling terminal"
of the process (i.e. the one where you typed in the command -- this is not
a precise definition of controlling terminal of course) so if you arrange
to read from /dev/tty you will be talking to the terminal not the file.
Look at man 4 tty for another description of this.
read cont < /dev/tty
works for me with bash.
John.
On Fri, 17 May 2002, César Soler wrote:
> Hi all,
>
> I would like to run an interactive script, but I'm a bit lost.
> Is there any way to read a value from the keyboard when the standard
> input has been assigned to a file into a sh-script? It means, into a
> script I have a while loop, like:
>
> cat $file | while read line;do
> [commands]
>
> echo "Continue(y/n)?"
> read cont
> if [ "$cont" = "n" ];then exit 1;fi
>
> [more commands]
> done
>
> In this way, cont is read from $file. Does anybody know how I could
> redirect again de standard input?
>
> Thanks in advance for your help!
>
> --
> Best regards,
> César mailto:csoler@euskalnet.net
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: standard redirections
2002-05-17 15:16 ` John Hallam
@ 2002-05-18 20:19 ` César Soler
0 siblings, 0 replies; 3+ messages in thread
From: César Soler @ 2002-05-18 20:19 UTC (permalink / raw)
To: John Hallam; +Cc: linux-admin, twalberg
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, 17 May 2002, John Hallam wrote:
> On most UNIX systems /dev/tty is the name for the "controlling terminal"
> of the process (i.e. the one where you typed in the command -- this is not
> a precise definition of controlling terminal of course) so if you arrange
> to read from /dev/tty you will be talking to the terminal not the file.
> Look at man 4 tty for another description of this.
>
> read cont < /dev/tty
>
> works for me with bash.
>
> John.
>
Thank you very much for your help and your time, as well as Tims'.
This also works in my case!
- -----------------------------------------------------------------------------
César Soler mailto: csoler@euskalnet.net
PGP KeyID: 0x179DAD53 at >>>>>>>>>>>>>>>>>>>>>>> http://search.keyserver.net/
- -----------------------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8
iQA/AwUBPOa3bRXze/0Xna1TEQKHiwCeNaVPWlan7TZvLPNvzWnKpwey1DEAoIUL
UfYc46EQApS0SwTe1X4qaNVf
=YCO4
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-05-18 20:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-17 13:22 standard redirections César Soler
2002-05-17 15:16 ` John Hallam
2002-05-18 20:19 ` César Soler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).