Executing Stdout ???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing Stdout ???
# 1  
Old 04-02-2008
Network Executing Stdout ???

Hiya all,

Simple question - yet no simple answer im afraid !

Is there a way to execute a shell script (child) which returns one line and get the current (parent) shell to execute the stdout from the child ???

example

child.sh
#!/bin/sh
echo "setenv DISPLAY xxx:03"

parent_prompt> ./child.sh
setenv DISPLAY xxx:03 #<--- parent would exe this line ????

many many thanks in advance for your feedback effort support and time in this .....
# 2  
Old 04-02-2008
parents executing what their kids make...! what has the world come to...?

Code:
man xargs

# 3  
Old 04-02-2008
And the answer is...

Code:
parent_prompt> eval `./child.sh`  # That's backticks, not quotes!

:-)

-c
# 4  
Old 04-02-2008
The parent process needs to invoke the child process using command substitution.

Code:
cat parent.ksh
#!/usr/bin/ksh

LINE=$(chld.sh)

and the child process should simply echo (return) the desired line.

Code:
cat child.ksh
#!/usr/bin/ksh

echo "setenv DISPLAY xxx:03"

# 5  
Old 04-02-2008
Shamrock -- that will only set LINE to whatever;s come from the child. You'd need another line to execute the contents of $LINE

-c
# 6  
Old 04-02-2008
Quote:
Originally Posted by craigp84
Shamrock -- that will only set LINE to whatever;s come from the child. You'd need another line to execute the contents of $LINE

-c
Correct craigp84...eval would be the way to go as shown in your post.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Stdout in file

I cannot figure out what is wrong.... I have 3 files with IP addresses: file1 134.123.3.236 file2 134.123.3.235 file3 134.123.5.237 I type "prob1 Oops x2x3x4". Then my code creates file with name Oops and first line x2x3x4. Moreover, my code generate IP and it gives to file Oops as a second... (1 Reply)
Discussion started by: Manu1234567
1 Replies

2. Cybersecurity

How do I wipe stdout?

Today I used Terminal (invoked from Mac OS X 10.4.11) to view some data that is secured by a password. After exiting Terminal, it occurred to me that a vestige of the data displayed on my screen might reside in memory or in disk file ... the actual file used for stdout, for example. Do I need... (1 Reply)
Discussion started by: dcollins
1 Replies

3. UNIX for Dummies Questions & Answers

STDout

Hi, I have a program set to read in a text file, change certain characters and then print the altered version to the screen but does anyone know how to save the new version as another text file? And, if possible, how to specify the file name, and perhaps location? Thanks! (2 Replies)
Discussion started by: PerlNutt
2 Replies

4. Shell Programming and Scripting

stderr/stdout

Can somebody explain to me why the diff output is not going to stderr? Yet when I issue a diff from the command line the return code is -ne 1. I am guessing diff always writes to stdout??? Is there away I can force the difff to write to stderr USING THE CURRENT template. If possible, I... (5 Replies)
Discussion started by: BeefStu
5 Replies

5. Shell Programming and Scripting

STDOUT in one line

Hi all, I got a file which contains this. aaaaaaaaaaaaaaaaaaaaaaaa test aaaaaaaaaaaaaa test aaaaaaaaaaa test aaaaaaaaaaaaaaaaa test aaaaaaaaaaaaaaaaaaaaa test aaaaaaaaa test aaaaa test and I want all test output in one row, ideally 3 spaces after the longest word. Thanks (4 Replies)
Discussion started by: stinkefisch
4 Replies

6. UNIX for Advanced & Expert Users

How to use gzip on stdout

Does anyone know how I can use gzip to zip a large log file on the fly. My simulation is currently logging a large file that I need for analysis at a later point. However the files are so huge that I may even run out of disk space. The content is mainly text so when compressed the files are... (2 Replies)
Discussion started by: mitch1710
2 Replies

7. Solaris

stdout redirected?

Hi all, I have a c++ program which is running fine but has some printfs which its spews on to the screen, which I need for debugging. But, I execute this program through a java, i.e I run a java program which actually launches my c++ executable and when it does this, I see none of my printfs... (1 Reply)
Discussion started by: Naanu
1 Replies

8. UNIX for Advanced & Expert Users

STDOUT truncation

Operating system - Solaris 8, Korn shell, xterm Command /usr/proc/bin/ptree outputs the process tree exactly as I want with all detail However, /usr/proc/bin/ptree | more truncates the process descriptions at an 80 character point. If the process tree has marched enough to the right,... (3 Replies)
Discussion started by: JerryHone
3 Replies

9. Programming

stdout to a variable?

Hi, I need to set stdout to go to a String variable, has anyone got any ideas? (6 Replies)
Discussion started by: cb.mark
6 Replies

10. Filesystems, Disks and Memory

where does stdout link to?

As I read the source code of unix I wonder where u_ofile(it should be stdout) link to ? Does it link to a file structure like ordinary files? :confused: (7 Replies)
Discussion started by: jiangyanna
7 Replies
Login or Register to Ask a Question