Urgent Help on "Script Command" on a shell script

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Urgent Help on "Script Command" on a shell script
# 1  
Old 06-25-2010
Urgent Help on "Script Command" on a shell script

Dear All,

I am trying to capture the terminal session using the script command. It works when i issue on that has a command. But it is not working on inside a shell script as it is expecting a exit command to come out. Even after I ran the script and it expects me type the exit command and not taking the exit command inside the script. This is urgent and can anyone help me ASAP.

This is the script I am using.

#!/bin/ksh
script
sleep 5
/sbin/initprivs
exit
exit
# 2  
Old 06-25-2010
Hi.

Suppose your script is "s1". I would remove the command script from file "s1", then run as:
Code:
script -c ./s1

It looks like you may be running on SCO. I don't have access to that, however, my suggestion worked on a Linux box.

cheers, drl
This User Gave Thanks to drl For This Post:
# 3  
Old 06-25-2010
Hi,

Thanks for your response. I am running this on SCO UNIXWARE 7.1.3.

It does not have the option -c, I ran and got the following error.

root# script -c ./test1.ksh
usage: script [ -a ] [ typescript ]
root#

Please advice if there is any other way work it around on the script.

Regards,

Ravoi
# 4  
Old 06-25-2010
I don't think that this can be done from a unix script. The "script" command intercepts commands typed from the keyboard and exits when it sees "exit" or ctrl/d. Even writing to the terminal device does not fool it.
An external workaround is to use a terminal scripting language such as that provided with WRQ Reflections (tm).

If all you want to do is record the output from the command (including error messages):
Code:
/sbin/initprivs 2>&1 >mylogfile

If you want to see what was output to standard output and record it:
Code:
/sbin/initprivs | tee mylogfile


Last edited by methyl; 06-25-2010 at 10:02 PM.. Reason: layout
This User Gave Thanks to methyl For This Post:
# 5  
Old 06-27-2010
try

exit 0
This User Gave Thanks to For This Post:
Bill L.
# 6  
Old 06-28-2010
i tried both of you suggested but still I am unable to catch the ouput of it.

I am also checking if there is any other way of doing it.

Any other ideas / suggestions?
# 7  
Old 06-28-2010
Hi.

Two possibilities, both of which might be a lot of work, both of which might not work:

1) Use expect, probably easy to install, requires tcl, but is not trivial to learn.

2) Download the package util-linux-ng from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/, which contains about 20 miscellaneous utilities, one of which is the version of script for Linux that I mentioned in an earlier post. All they supply is source, so you'd need to do the compile, etc. I'm using version 2.13.1.1, they are up to 2.18. I'm sure it could become very messy very quickly, trying to port from Linux to SCO.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

expect script not running in cron "Urgent"

I wrote a script to download the files from sftp location to local. while running the script manually its working fine. when i schedule the same in cron its not working.... :wall::wall: here is the script: #!/bin/bash ... (2 Replies)
Discussion started by: ganga39
2 Replies

3. Shell Programming and Scripting

Script invoked using "sh" is not executing. Urgent help required

Hi , I am new to shell scripting. I am using Linux for doing scripting. Below is my script, which takes 2 parameters as input. test.sh has the below: #!/bin/bash . $HOME/.profile gpg --yes --no-use-agent -r "$(eval echo \$$2_Var)" -e $1 1st parameter is command line... (7 Replies)
Discussion started by: rangarb
7 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. Shell Programming and Scripting

"sed" command is not working in shell script

Hi All, I am not much strong in shell scripting... I am using sed command in my script to find and replace a string....... This is how script looks : ############# #!/usr/bin/ksh CONFIG_FILE=iom_test.txt FIND=`echo "NIS_FTP_SERVER1=123.456.iom.com"` REPLACE=`echo... (2 Replies)
Discussion started by: askumarece
2 Replies

8. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

9. Shell Programming and Scripting

passing a list of dynamic names to a "PS" command in shell script?

Hi, I am new to shell script. This is my first post .I have written a small script which returns list of names starts with "ram" in /etc/passwd .Here is that:- #!/bin/ksh NAME_LIST="name_list.txt" cat /dev/null > $NAME_LIST evalcmd="cat /etc/passwd | grep "^ram?*" | cut -d: -f1" eval... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies

10. Shell Programming and Scripting

Q: Recording shell script screen output using "script" command ?

Hello, I need to capture everything showed on a screen by a shell script which needs user interaction. The shell script performs commads such as rsh so normal redirection to a file does not work. I know there is a special unix command call "script" which records screen session but the... (4 Replies)
Discussion started by: lalfonso.gomez
4 Replies
Login or Register to Ask a Question