LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-30-2002, 12:45 PM   #1
tn1681
LQ Newbie
 
Registered: Jul 2002
Posts: 12

Rep: Reputation: 0
capturing STDOUT to file.


I have a Bourne shell script that is calling a command line from another program on the same platform.
I am attempting to redirect the output of this command line to a file so I can use the entries in this a file as variables for another command line.

The redirect and/or pipe to tee creates the file, but there is nothing in the file....

Here is how I have tried it...

cftshell "command" | tee tmpfile
and
cftshell "command" > tmpfile

cftshell invokes a set of commands
"command" is command within cftshell
output dumps to STDOUT


#Must be in " " for cftshell to accept command from sh

Here is what the output looks like from command normally...

PORT=7-H'1a2d

I need this information in a file.

Both are creating a file, neither are capturing the data to STDOUT and putting the information into the file.

Any help would be appreciated.
 
Old 10-30-2002, 12:54 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
this cftshell thing is your own creation then? well if that's how the program is to be used, why not just redirect the programs outupt inside the program, with a second parameter being an output file?
 
Old 10-30-2002, 01:12 PM   #3
tn1681
LQ Newbie
 
Registered: Jul 2002
Posts: 12

Original Poster
Rep: Reputation: 0
STDOUT

No.
This is a built in utility, (on a running program), that I am calling to get a piece of information I need quickly.

Is there not a way to capture the STDOUT of this to a file?
 
Old 10-30-2002, 01:24 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,655

Rep: Reputation: 210Reputation: 210Reputation: 210
Maybe it's not redirecting output to stdout? if it does, soemthing like
cftshell "command" > tmpfile
should work correctly. Maybe try with stderr:
cftshell "command" 2> tmpfile
 
Old 10-30-2002, 02:53 PM   #5
tn1681
LQ Newbie
 
Registered: Jul 2002
Posts: 12

Original Poster
Rep: Reputation: 0
STDOUT

Mara...

Using the cftshell "command" 2> tmpfile does appear to be attempting to capture the output of the command.

However, there is a delay between the execution of the command and the output to STDOUT/STDERR.

There is an initial message "XXX", that appears on the screen as the cftshell command executes. (This is appropriate).

This is all I am capturing to the file.

If I put a "sleep 5" in between, I lose it all.

I need a short delay in there to capture the info that is being dumped to the terminal prior to the script continuing.

I appreciate your help.

Still working on it.
 
Old 11-01-2002, 11:51 AM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,655

Rep: Reputation: 210Reputation: 210Reputation: 210
When you run
cftshell "command" 2> tmpfile
you capture the whole "command" output to standard error to file... Do you get only the single message? The program may be redirecting the output in a different way. Maybe try something different like:
cftshell "command" 1> tmpfile1 2>tempfile2
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Redirecting to file and stdout Quantum0726 Programming 3 11-14-2005 08:35 PM
stdout to file Machiaveli Programming 8 09-04-2005 08:53 AM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 07:55 AM
how to output stdout to a file SciYro Linux - Newbie 4 02-25-2004 05:08 PM
Redirecting stdout from tar to a text file. heatlill Programming 2 01-22-2002 10:27 AM

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

All times are GMT -5. The time now is 11:12 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration