How do I execute "script" within a c script?

How do I execute "script" within a c script?

Post by Sand » Fri, 12 Jan 2001 06:55:10



HI,
I'm running HP unix and I want to execute the "script" command within a c
script so that I can log all the events that took place when I ran the
script. I tried putting "script file" in the c script and when it got to
that point my script stopped. It seemed like it opened another shell or
something.

Maybe using "script" isn't the way to go.

?????

 
 
 

How do I execute "script" within a c script?

Post by Jim Liedek » Fri, 12 Jan 2001 10:51:08


By c script do you mean c-shell?  There is a switch for shell scripts (-x)
that echoes each command with shell substitutions in place to standard out.
You could capture everything into a file and then throw away the parts you
don't want.  Or you could use the (-v) switch which only echoes the command
as written before execution.

Actually I'm not sure if these switches are available in C-shell.  They
exist for TCSH and BASH.

PS: C-Shell programming is considered harmful.


> HI,
> I'm running HP unix and I want to execute the "script" command within a c
> script so that I can log all the events that took place when I ran the
> script. I tried putting "script file" in the c script and when it got to
> that point my script stopped. It seemed like it opened another shell or
> something.

> Maybe using "script" isn't the way to go.

> ?????

--
If people don't want to come to the park, how are you gonna stop them.
     -- Yogi Berra

 
 
 

How do I execute "script" within a c script?

Post by Barry Margoli » Sat, 13 Jan 2001 01:13:52




Quote:>By c script do you mean c-shell?  There is a switch for shell scripts (-x)
>that echoes each command with shell substitutions in place to standard out.
>You could capture everything into a file and then throw away the parts you
>don't want.  Or you could use the (-v) switch which only echoes the command
>as written before execution.

>Actually I'm not sure if these switches are available in C-shell.  They
>exist for TCSH and BASH.

In csh you use the "set echo" and "set verbose" commands to make it display
what it's doing.

--

Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

How do I execute "script" within a c script?

Post by bpc » Sat, 13 Jan 2001 12:56:50




Quote:> By c script do you mean c-shell?  There is a switch for shell scripts
(-x)
> that echoes each command with shell substitutions in place to
standard out.
> You could capture everything into a file and then throw away the
parts you
> don't want.  Or you could use the (-v) switch which only echoes the
command
> as written before execution.

> Actually I'm not sure if these switches are available in C-shell.
They
> exist for TCSH and BASH.

-v and -x are both available in the C shell (e.g. '#!/bin/csh -x). Main
other useful one is -f (for fast - ignore the .cshrc and .login files),
which you should always use unless there's a good reason - should set
the environment explicitly within the script.

Ben

Sent via Deja.com
http://www.deja.com/

 
 
 

1. How to specify a program to be executed within the function "script"?

Dear all,

Problem:
=======
  You probably know the function (1) script

  % script(1)
  %
  % NAME
  %   script - make typescript of terminal session
  %
  % SYNOPSIS
  %   script [-a] [file]
  %
  % DESCRIPTION
  %   script makes a typescript of everything printed on your terminal.
It
  %   starts a shell named by the SHELL environment variable, or by
default
  %   /usr/bin/sh, and silently records a copy of output to your
terminal
  %   from that shell or its descendents, using a pseudo-terminal device
  %   (see pty(7)).

  I wanted to do something like:
    script trace_file << EOF
      pwd
      ls -al *
      rm -i  *
    EOF

  The idea is to keep a trace of all what was done during the execution
  of a set of commands, particularly if the commands are interactive.

Questions:
=========
  Is it possible to give it any parameter to be executed automatically ?
  If no,  why ? Does it exists any workaround ?
  If yes, how ?

References:
==========
  I didn't found any usefull information in:
  - UNIX FAQ (in this newsgroup)
  - Korn Shell, O'Reilly

Environment:
===========
  I'n not particularly linked to:
  - a shell (sh, posix-sh, ksh, csh are OK)
  - an operating system (HP-UX 9.x, 10.x, 11.x; Solaris 2.5, 2.6; ...)

--
Best regards, Ph. Kipfer
------------------------------------------------------------------------
  Hewlett-Packard (Switzerland) AG     Phone:    +41 (0)31 980 31 11  
  Philippe Kipfer                      Fax:      +41 (0)31 980 33 90
  Meriedweg 11                         Telnet:   780-3352

  X400:S=Kipfer/G=Philippe/C=CH/A=400NET/P=HP/O=HP/
       OU1=HP-Switzerland/OU2=OM3
========================================================================

2. Lost packets on LAN - HELP!!!

3. "man2ascii"-script ( was: Re: Is there a "man2ascii"-script???? )

4. Unix for beginners

5. "kill" group of commands from within script

6. Fujitsu ATAPI MO Drive

7. "script" command within a shellscript... help!

8. OOB Data, signals, and forks, OH MY!

9. "lcd" Within an FTP Script

10. GETSERVBYNAME()????????????????????"""""""""""""

11. Calling External Scripts From Within A "setld" SCP?

12. "No such file or directory" when executing script

13. "cd /etc" doesn't work when executed from a script?