← Back to team overview

sslug-teknik team mailing list archive

Re: pause til scripts

 

On Fri, 9 May 2003, Jon Svejgaard wrote:

> > Jeg mangler en lille kommando til flere af mine scripts: pause, eller 

> #include <stdio.h>

Det er måske lidt overkill at skrive et helt C program til det?

> 
> main(argc,argv)
> int argc;
> char **argv;
> 
> {
>          char s[10];
>          while (--argc) printf("%s ",*++argv);
>          printf("\nTryk <RETURN> for at fortsætte...");
>          gets(s);

Fra man siden:
BUGS

       Never use gets().  Because it is impossible to tell without knowing the
       data in advance how many  characters  gets()  will  read,  and because
       gets() will continue to store characters past the end of the buffer, it
       is extremely dangerous to use.  It has  been  used  to  break  computer
       security.  Use fgets() instead.

Ovenstående kan iøvrigt opnås med f.eks.:
echo -e -n "Hello World\nTryk <RETURN> for at forsætte..." && read a

read er en bash ting, men formentlig posix

help read

Prøv f.eks. også:

echo -e -n "Hello World\n" && read -p "Tryk en tast for at forsætte..." -n 1 a ; echo forsat

Mads

-- 
Mads Bondo Dydensborg.                               madsdyd@xxxxxxxxxxxx
I don't say this lightly. However, I really think that the U.S. no longer
is classifiable as a democracy, but rather as a plutocracy.
                               - H. Peter Anvin




Follow ups

References