Sponsored Content
Top Forums Shell Programming and Scripting How to get return value from C program and logs to file Post 302173183 by yhacks on Thursday 6th of March 2008 12:21:24 AM
Old 03-06-2008
Bug $PIPESTATUS not printing any value

echo "Running program output"
myLine="./add 1 11"
`expr "$myLine"`| tee outputfile
echo "Pass / Fail : $PIPESTATUS"

Thanks for your reply.
$PIPESTATUS is not printing any value when it is written in script
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

2. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies

3. Shell Programming and Scripting

How to capture C program return values in Kshell

I have a K shell script (ksh) that needs to return an email address. A C program was written (prog1) to now access the email address off of an oracle table. The call to the program in the ksh is prog1 -p parm1 Based on Parm1 the program will read an oracle table and retrieve the email... (2 Replies)
Discussion started by: jclanc8
2 Replies

4. Shell Programming and Scripting

Trapping program return code

Hello I have a program (prog) that accepts a parameter in order to execute some internal loop grabbing memory in each iteration. I'm using top to monitor the memory usage and to produce an output. Thus I need the program's pid as a parameter to top. I capture pid using myPID=$!. I'm also... (5 Replies)
Discussion started by: pavlosgr
5 Replies

5. Programming

Parallel Processing Detection and Program Return Value Detection

Hey, for the purpose of a research project I need to know if a specific type of parallel processing is being utilized by any user-run programs. Is there a way to detect whether a program either returns a value to another program at the end of execution, or just utilizes any form of parallel... (4 Replies)
Discussion started by: azar.zorn
4 Replies

6. UNIX for Dummies Questions & Answers

Program: How to FTP logs from a Server to Desktop

Hi guys, Good day! Anyone there could suggest on how can I create a program that will get (ftp) the logs I need from a remote Server (running in Linux) into my Desktop (running in Windows 7). For Perl program suggestions, FYI that I'm using Active Perl version. The reason why I need this one is... (2 Replies)
Discussion started by: rymnd_12345
2 Replies

7. Shell Programming and Scripting

How to end the program with a successful return code?

i have the follow shell script that try to find any file in the specified path and upload to oracle. if no file will output in the concurrent log and the program return as error , how do i change the program so that if no file found will give out normal sucessful result. i tried change the exit... (3 Replies)
Discussion started by: feilhk
3 Replies

8. UNIX for Advanced & Expert Users

File command return wrong filetype while file holds group separator char.

hi, I am trying to get the FileType using the File command. I have one file, which holds Group separator along with ASCII character. It's a Text file. But when I ran the File command the FileType is coming as "data". It should be "ASCII, Text file". Is the latest version of File... (6 Replies)
Discussion started by: Arpitak29
6 Replies

9. Programming

Segment fault for C++ program when return vector

I am trying to reverse complement DNA sequence (string) with a short c++ code using boost library. Code was compiled without any warning/error, but ran into Segmentation fault. My guess is the function to return a vector, but not sure. #include <iostream> #include <fstream> #include <string>... (14 Replies)
Discussion started by: yifangt
14 Replies

10. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies
hexec(1)																  hexec(1)

NAME
hexec - a process execution hooking tool SYNOPSIS
hexec <OPTIONS> [expr] [cmd] [args...] DESCRIPTION
hexec is a tool to hook into process exececution calls (exec family of syscalls). You can define an expression that is executed against any hooked exec call. This expression may also contain a replacement exec call. OPTIONS SUMMARY
Here is a summary of the options to hexec. --help | -h Print a options/expr summary page --version | -v Print hexec version --log-out | -lo set output file for error and -print output OPTIONS
-h Print a options/expr summary page --help Print a options/expr summary page -lo Set the output file for error and -print output. This can be required if writing to stderr could cause malfunction because some processes read from stderr and expect a well defined output. EXPRESSIONS
The expression is executed against all process execution calls. If the expression returns true, the original call is skipped. <expr> -and <expr> <expr> -a <expr> <expr> <expr> Returns true if both expressions return true. If the left returns false, the right expression is never executed. <expr> -or <expr> <expr> -o <expr> Returns true if one of both expressions returns true. If the left returns true, the right expression is never executed. -path <pattern> Returns true if the path of the executable matches <pattern>. <pattern> is a bash compatible wild card pattern. -ipath <pattern> Same as -path, but case insensitive. -name <pattern> Returns true if the base name of the executable matches <pattern>. <pattern> is a bash compatible wild card pattern. -iname <pattern> Same as -name, but case insensitive. -contains <str> Returns true if the path of the executable containes the string <str>. -icontains <str> Same as -contains, but case insensitive. -print Print all arguments to the called process. Returns always true. -exec <cmd> [args...] ; Executes <cmd> with [args...] as arguments. This expression must be terminated with a semicolon. You can use argument placeholders in <cmd> and [args...] (see below). This expression always returns true. NOTE: Please be aware that you may need to escape or quote the terminating semicolon to not confuse your shell. -sh <script> Interprets <script> as a shell script by invoking /bin/sh with the arguments -c '<script>'. You can use argument placeholders inside <script>. Please note that -sh only expects a single argument and not a variable list of arguments (as -exec does). Using -sh is the same as using -exec sh -c <script>. PLACEHOLDERS FOR -exec EXPRESSION Every -exec expression can use placeholders in the argument list to obtain information from the original exec call. Each placeholder starts with { and ends with }. Use { if you want to use a { in your argument list. The placeholders are replaced when the -exec expression is evaluated. Placeholder types: {n} Will be replaced with the number of arguments in the original call. {<idx>} Will be replaced with the original argument at index <idx>. Example: {1} would give the first argument. You can prepend <idx> with placeholder flags. {} Will be replaced with all arguments from the original call. Each argument is seperated with a space. You can use placeholder flags. NOTE: The executable name is also considered as argument. This means that a call like "echo test" will result in two arguments, "echo" and "test". PLACEHOLDER FLAGS
s Every argument is inserted as single argument instead of concatenating all arguments. Consider the arguments 'a', 'b' and 'c'. Without s, -exec {} ; would result in -exec 'a b c' ;, which in many cases is not what you want. -exec {s} ; howewer would result in -exec 'a' 'b' 'c' ;. q Quote every single argument. e Escape all non alpha-numeric characters. This flag is very useful when using a "sh -c <...>" in the -exec expression. Examples -exec echo {} ; with the call 'a' 'b' 'c' results in: 'echo' 'a b c' -exec echo {q} ; with the call 'a' 'b' 'c' results in: 'echo' 'a' 'b' 'c' -exec sh -c 'echo {}; {}' ; with the call 'sh' '-c' 'gcc d.c >> log.txt' results in: 'sh' '-c' 'echo sh -c gcc d.c >> log.txt; sh -c gcc d.c >> log.txt' Please note that this will not do what you may expect, as the >> is handled wrong in this case. -exec sh -c 'echo {e}; {}' ; with the call 'sh' '-c' 'gcc d.c >> log.txt' results in: 'sh' '-c' 'echo sh -c gcc d.c >> log.txt; sh -c gcc d.c >> log.txt' CHANGES TO PROCESSES
hexec will add some environment variables to the hooked processes. These are (may not be complete): LD_PRELOAD hexec adds libhexec-hook.so to the list of preloaded libraries. HEXEC_EXPR_SHM Contains the name of the internal shared memory object. HEXEC_LOG_FD Contains the file descriptor for error and -print output. Please do never modify these environment variables. Also take care when you use these variables, because the name and content of the vari- ables may change in the future. EXAMPLES
hexec -name 'gcc' -exec ccache {s} ; make Calls make, which will then call gcc several times. The executable name of each hooked process execution is tested against the file pattern "gcc" and "ccache {s}" is called each time a match is found. '{s}' will be replaced with the original (the hooked) call. In this example, a call to "gcc -o test.o test.c" would be replaced with "ccache gcc -o test.o test.c" HOW IT WORKS
TODO BUGS
I'm sure there are alot...it's still beta :) AUTHOR
hexec was written by Alexander Block http://blocksoftware.net/ If you wish to report a problem or make a suggestion then please email ablock@blocksoftware.net hexec is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details. November 2008 hexec(1)
All times are GMT -4. The time now is 01:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy