Set variable to program message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Set variable to program message
# 1  
Old 09-03-2012
Set variable to program message

I have a TCSH script that calls a program. This program generates a file and outputs a message to the terminal window. Is there a way to store the message it outputs to a variable...so I can use it in my script?
# 2  
Old 09-03-2012
In the called program you should be able to "return" with the msg variable as a parameter or in the called program print/echo the msg to stdout and call the program from your script like this:
Code:
msg=`program_name`

# 3  
Old 09-04-2012
The program I am calling...I take its output and write it to a file, but the program writes if it was successful or not to the terminal window. I do not have access to manipulate the program...so I just want to capture its terminal window output to a variable.
Here's an example from my script (program is called and writes its output to test.txt):
program_name > test.txt

One example of the program's terminal window output that I want to store in a variable:
program successfully completed

So...is there a way to store this terminal window message to a variable?
# 4  
Old 09-04-2012
Call the program redirecting stdout and stderr to output file and see if what is getting written to screen gets written to file:
Code:
program_name >test.txt &2>1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Can C program put message to IBM MQ remotely, if local server doesn't have MQ library?

Can somebody know if it is possible to connect to remote IBM MQ, if local server using C, but don't have MQ library? Thanks for contribution (0 Replies)
Discussion started by: digioleg54
0 Replies

2. Shell Programming and Scripting

How to display a message if program hangs(takes too long)

I have a ksh script (script1) that calls another ksh script (script2). If script2.ksh hangs or takes too long to execute I want script1.ksh to kill the call to script2.ksh and instead just display "Script2 can't run right now". Could someone help me with coding this? (1 Reply)
Discussion started by: mrskittles99
1 Replies

3. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

4. Programming

Set host default gateway in C program.

Hello everybody, I'm having troubles on setting the default gateway address (and other addresses, such as netmask, or ip) of the host running a C program. I know it has to be with ioctl, but don't know how to do it. Could somebody give me an example on how to set the default gateway address of... (4 Replies)
Discussion started by: semash!
4 Replies

5. Red Hat

Message parsing interface (MPI) program

Hi, I need to install the following program on my Linux box (Red Hat) Software for Pyrosequencing Noise Removal The software only runs on Linux computers with MPI -I do not have MPI on my computer. I was hoping someone could please point me in the right direction so I can download and... (2 Replies)
Discussion started by: Xterra
2 Replies

6. UNIX for Advanced & Expert Users

Finding register set being used in program

How can i find( or list) contents of all registers being used by my program? Is there any system call or library available for this?:confused: At runtime in my c/c++ program. At runtime using may be some assembly hack!!!!!!!!!!! (2 Replies)
Discussion started by: amit gangarade
2 Replies

7. Fedora

set path using a shell program

Hello sir, I am using a fedora 9 system. I wanted to update the path to include the $HOME into the path. So what we do is : This will update the path. I want to do the same thing by writing it in a shell prgram. I wrote the above code in an "a.sh" file and executed it using "bash a.sh".BUt... (1 Reply)
Discussion started by: nsharath
1 Replies

8. Programming

C++ map program - Error message

Hi All I am compiling a STL map program in HP-UX using aCC compiler #include <iostream.h> #include <sys/map.h> #include <string> #include <string.h> int main() { map<string, long> directory; } $ aCC map3.cpp Error 318: "map3.cpp", line 7 # A template name was expected... (0 Replies)
Discussion started by: dhanamurthy
0 Replies

9. Linux

Where to set program arguments in DDD debugger?

In DDD debugger, where to set the the arguments for main program? For example: ./myExe "argv1" "argv2" -> where to set "argv1" & "argv2" ? Thanks! (2 Replies)
Discussion started by: princelinux
2 Replies

10. UNIX for Dummies Questions & Answers

Export command giving Variable Name vs the Value set for the Variable

I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so: set -a export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data" export... (2 Replies)
Discussion started by: ParNone
2 Replies
Login or Register to Ask a Question