Save output in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Save output in a variable
# 8  
Old 05-24-2010
angshuman_ag, you might want to actually lay out the entire script, including the shebang for us to assist further. This is at least your second thread on this topic, all of which seem to meander back to befuddled.

While we'd like to assist, without more than 'no work' responses, we cannot assist on conjecture. What is your script? What are the args? What is the output to screen...or the return code you're seeing?
# 9  
Old 05-24-2010
I have already laid out the entire script. Its a custom 3rd party tool which return a string always to the console in case of error or success. So, I want to capture that string output in a variable so that I can log that string for debugging purpose. That is the only requirement. If I had the source code of that tool, I could have figured out myself. But, since I have only this much information, hence I thought of posting in this forum.
# 10  
Old 05-24-2010
Quote:
I have already laid out the entire script. Its a custom 3rd party tool which return a string always to the console in case of error or success.
OK, you now have provided us with another bit of very valuable information. What console is it returning the error to? What system is this on? Is it a GUI or a command line executable?
# 11  
Old 05-24-2010
I don't see a script...although I do see individual command-line calls. Perhaps you're confusing the notion of a script? What shell is it this time? Is it still csh? Previous thread was focused on ksh application of the approach.

If it's on Solaris, have you polled the /var/adm/messages file to see if it's already outputting to a system log?
# 12  
Old 05-24-2010
Hi,
As I have previously said, its a C SHELL on Solaris 8. And, again I will post the "myScript". It looks like this after your suggestion-
Code:
set output=`/usr/bin/convert -f inputfile.xcf`
echo "test:\n$output"

Still the above code outputs everything to the console UNIX window when I execute the script like this ./myScript. It echoes its own success/error string in the 1st line on the window followed by "test:" and a BLANK newline. So, the output variable does not have anything yet.

(It does not outputs anyting to system logs). I want to capture the part of string which it echoes before "test:" inside a variable.

Last edited by angshuman_ag; 05-24-2010 at 02:15 PM.. Reason: More Clarity
# 13  
Old 05-24-2010
does this 'convert' program provide either a --help (or -h) option, a man page or any sort of usage? does it maintain it's own logging, if it's part of a larger application? are we talking Gimp picture files...?
# 14  
Old 05-24-2010
Hi,
These are custom files which have their own format. There is no problem with the conversion or the tool. Its working fine. The only problem is storing its output string.

The help which it provides is very minimal. There are only two options , one which I have provided and other one is -outdir which will put the converted file to the mentioned folder (if provided). There is no man page entry too. Also, it does not maintains any logs. Whatever is there it outputs to the console window. Same output I want to capture.

Thats all the information I have.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Save value from output of Corestat and save in a list for each core

I am trying to modify the "corestat v1.1" code which is in Perl.The typical output of this code is below: Core Utilization CoreId %Usr %Sys %Total ------ ----- ----- ------ 5 4.91 0.01 4.92 6 0.06 ... (0 Replies)
Discussion started by: Zam_1234
0 Replies

2. UNIX for Dummies Questions & Answers

I save the result in a variable

I have friends that this command worked perfectly, but I would like to save the result in a variable, which I have not achieved var=prueba.txt echo $var | cut -d "." -f 1 prueba I need to do this but does not work me salida=echo $var | cut -d "." -f 1 echo "result:$salida" ... (8 Replies)
Discussion started by: tricampeon81
8 Replies

3. Programming

Save output in text C++

Hi , i want to save the output of my c ++ code to a text file which is in a particular path : this is part of my code and I dunno where I am doing it wrong do { for( int i = 0; i < l; ++i ) { std::cout << 1 + k * i + index << ' '; } ... (2 Replies)
Discussion started by: siya@
2 Replies

4. UNIX for Dummies Questions & Answers

Solved: how to save an output to a variable

i want to save the output of /scripts/whoowns domain.com to a username like $user = /scripts/whoowns domain.com but I'm not sure how to do that This is inside a bash script how can I get the output of /scripts/whoowns then save that to a variable? thanks! ---------- Post updated at... (0 Replies)
Discussion started by: vanessafan99
0 Replies

5. Shell Programming and Scripting

how can save output?

I make shell script by use "if" statement, what should add it to shell script save which I enter it in output file txt? ---------- Post updated at 08:27 AM ---------- Previous update was at 05:59 AM ---------- I mean like this echo "enter your name" read name # now i when start... (1 Reply)
Discussion started by: Oman_Member
1 Replies

6. Shell Programming and Scripting

how to save an output of a command in a variable

Hi, in shell script, i have the command swstart -p which returns an output. i want to store the output of this command into a variable. how i can do that excerpt from the script #!/usr/bin/ksh # # # # Program: swstart -p # # Description: Starts the sentinels on Slave server ... (4 Replies)
Discussion started by: lookinginfo
4 Replies

7. Shell Programming and Scripting

Save cURL verbose output to file or do it like browser "save as.."

hi there ! i have exactly the same problem like this guy here https://www.unix.com/shell-programming-scripting/127668-getting-curl-output-verbose-file.html i am not able to save the curl verbose output.. the sollution in this thread (redirecting stderr to a file) does not work for me.... (0 Replies)
Discussion started by: crabmeat
0 Replies

8. Shell Programming and Scripting

to save output of a command in hash variable

Hi all, is it possible to save the output of a unix command executed in perl to be saved in hash variable.. like i have the command `find $mypath ! -user mainuser -printf \"\%u \%h\\n\"`; this will print all the users other than mainuser with their paths. so is possible to capture... (2 Replies)
Discussion started by: saapa
2 Replies

9. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

10. AIX

topas -P save output

hi i have server monitor script which totally depends upon the output of TOP which works fine on HP. now i am told to put same script on aix i found that topas -P produces same output but it doesnt redirect output to file i have to kill/terminate it. is there any other way to this. as the... (0 Replies)
Discussion started by: zedex
0 Replies
Login or Register to Ask a Question