LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2008, 09:11 AM   #1
the_imax
Member
 
Registered: Apr 2004
Distribution: RHEL 4/ CentOS
Posts: 159

Rep: Reputation: 30
using 'script' command


Hi
I am using a command "script" to capture the output of a terminal
my script is

#/bin/sh
script outputfile.txt
./execute_some_script.sh
exit
exit

Now my problem is that when my script run "script outputfile.txt" it forks a new shell and after that no other command executes.
The remaining command executes after I type exit on the terminal

So help me , so that this script executes the "./execute_some_script.sh" after running script "outputfile.txt" and also exists, so that the command outputs gets populated in outputfile
 
Old 09-16-2008, 09:39 AM   #2
fredgc
LQ Newbie
 
Registered: Aug 2008
Location: Seattle
Posts: 4

Rep: Reputation: 0
You want to try something like this instead:

#/bin/sh
script -c ./execute_some_script.sh outputfile.txt
exit


Make sure that the sub-script is executable:
chmod +x ./execute_some_script.sh

-- Fred GC.
 
Old 09-16-2008, 09:46 AM   #3
the_imax
Member
 
Registered: Apr 2004
Distribution: RHEL 4/ CentOS
Posts: 159

Original Poster
Rep: Reputation: 30
Hi
Sorry, I forgot to tell I am at Solaris and there is no -c switch with script
 
Old 09-16-2008, 09:54 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Why not just re-direct the output of the script to your output file?
Code:
#/bin/sh
 
./execute_some_script.sh > outputfile.txt 2>&1
 
Old 09-16-2008, 11:33 AM   #5
the_imax
Member
 
Registered: Apr 2004
Distribution: RHEL 4/ CentOS
Posts: 159

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
Why not just re-direct the output of the script to your output file?
Code:
#/bin/sh
 
./execute_some_script.sh > outputfile.txt 2>&1
I am afraid that redirecting output is not an option, from the script I want to telnet to a router and save the output of certain commands and redirect won't save that, the only option is to capture the terminal output log which is possible by the script command

Please correct me if I am wrong

Thanks
 
Old 09-16-2008, 11:38 AM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You might want to read up on using "expect" if it is installed on your system.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What does this script command mean? ubume2 Linux - Newbie 3 05-23-2008 02:38 PM
script command shan_nathan Linux - Security 1 01-07-2008 08:00 AM
Help on a command for a script. assasukasse Linux - Newbie 6 06-05-2006 08:36 AM
script command trasher Linux - Newbie 5 02-06-2006 06:20 AM
Command in shell script Grassie Coetzee Linux - Software 1 03-13-2005 11:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration