diff options
author | Karel Zak | 2006-12-07 00:26:12 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:26:12 +0100 |
commit | df1dddf9ffcfc1e291de809c0e8b9060bfea02ee (patch) | |
tree | 03b712bddec33d05754bf59d31a75d7e2022761e /misc-utils | |
parent | Imported from util-linux-2.11y tarball. (diff) | |
download | kernel-qcow2-util-linux-df1dddf9ffcfc1e291de809c0e8b9060bfea02ee.tar.gz kernel-qcow2-util-linux-df1dddf9ffcfc1e291de809c0e8b9060bfea02ee.tar.xz kernel-qcow2-util-linux-df1dddf9ffcfc1e291de809c0e8b9060bfea02ee.zip |
Imported from util-linux-2.12 tarball.
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/README.script | 7 | ||||
-rw-r--r-- | misc-utils/script.1 | 5 | ||||
-rw-r--r-- | misc-utils/script.c | 30 |
3 files changed, 27 insertions, 15 deletions
diff --git a/misc-utils/README.script b/misc-utils/README.script deleted file mode 100644 index 83dfcc5da..000000000 --- a/misc-utils/README.script +++ /dev/null @@ -1,7 +0,0 @@ -Here is a working version of the BSD script command which captures -the output of a terminal session in a file. - -If you have libc-4.2 you don't need cfmakeraw.c or paths.h - -Rick Sladkey -jrs@world.std.com diff --git a/misc-utils/script.1 b/misc-utils/script.1 index 6e987732e..b8e543773 100644 --- a/misc-utils/script.1 +++ b/misc-utils/script.1 @@ -40,6 +40,7 @@ .Sh SYNOPSIS .Nm script .Op Fl a +.Op Fl c Ar COMMAND .Op Fl f .Op Fl q .Op Fl t @@ -69,6 +70,10 @@ Append the output to or .Pa typescript , retaining the prior contents. +.It Fl c Ar COMMAND +Run the COMMAND rather than an interactive shell. +This makes it easy for a script to capture the output of a program that +behaves differently when its stdout is not a tty. .It Fl f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can diff --git a/misc-utils/script.c b/misc-utils/script.c index ec98ea1a4..fc913f431 100644 --- a/misc-utils/script.c +++ b/misc-utils/script.c @@ -91,6 +91,7 @@ int l; char line[] = "/dev/ptyXX"; #endif int aflg = 0; +char *cflg = NULL; int fflg = 0; int qflg = 0; int tflg = 0; @@ -135,11 +136,14 @@ main(int argc, char **argv) { } } - while ((ch = getopt(argc, argv, "afqt")) != -1) + while ((ch = getopt(argc, argv, "ac:fqt")) != -1) switch((char)ch) { case 'a': aflg++; break; + case 'c': + cflg = optarg; + break; case 'f': fflg++; break; @@ -284,7 +288,9 @@ dooutput() { void doshell() { - /*** + char *shname; + +#if 0 int t; t = open(_PATH_TTY, O_RDWR); @@ -292,7 +298,8 @@ doshell() { (void) ioctl(t, TIOCNOTTY, (char *)0); (void) close(t); } - ***/ +#endif + getslave(); (void) close(master); (void) fclose(fscript); @@ -300,11 +307,18 @@ doshell() { (void) dup2(slave, 1); (void) dup2(slave, 2); (void) close(slave); -#ifdef __linux__ - execl(shell, strrchr(shell, '/') + 1, "-i", 0); -#else - execl(shell, "sh", "-i", 0); -#endif + + shname = strrchr(shell, '/'); + if (shname) + shname++; + else + shname = shell; + + if (cflg) + execl(shell, shname, "-c", cflg, 0); + else + execl(shell, shname, "-i", 0); + perror(shell); fail(); } |