Capturing output from C++ program


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Capturing output from C++ program
# 1  
Old 03-07-2005
Capturing output from C++ program

Hi
I have a C++ program that generates a lot of log information on the console, I need this output (printed using printf function) to go to a file since I will use crontab to schedule the job.

I know I can do this:
myprog > myfile
but I don't know how to enter this in crontab.

I use Sun/Solaris


Thanks much.

Smilie
# 2  
Old 03-07-2005
You can do exactly that in a crontab entry. But more usual might be:
myprog > myfile 2>&1
to capture errors as well.
# 3  
Old 03-08-2005
You have to see crontab man page first as,
Code:
man crontab

Try as,

crontab -e
* * * * * <C++ program binary location> 1>> <logfile> 2>&1
save that one and you have to get new crontab installed message.

where 1>> is used to append contents. IF you don't want then use as 1>

It will execute your program every minute. Cron log information will be in /var/log/cron file.
# 4  
Old 03-08-2005
Thanks much guys Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help capturing output of expect script

match_max 500000 set timeout 30 set outcome1 {} set outcome2 {} set inputfile C:\\Users\\Administrator\\Desktop\\inputfile.txt send -i $con "\r"; expect -i $con "Desktop>" { exp_send "type $inputfile \r" } set timeout 30 expect { "Desktop>" { set outcome $expect_out(0,string);}... (3 Replies)
Discussion started by: cityprince143
3 Replies

2. Shell Programming and Scripting

Capturing Output?

Hello All, I'm writing a Bash Script and in it I execute a piped command within a Function I wrote and I can't seem to redirect the stderr from the 1st pipe to stdout..? I'm setting the output to an Array "COMMAND_OUTPUT" and splitting on newlines using this --> "( $(...) )". By putting... (6 Replies)
Discussion started by: mrm5102
6 Replies

3. Shell Programming and Scripting

Capturing the output of a background job

Hello, I unfortunately have a process that does two things, it returns an answer to me and then does a bunch of work that I would like to wait on. Here is a simple example: #!/bin/bash function p_w { echo "poopy" sleep 10 echo "scoop" } foo=$(p_w &) sleep 1 echo "1... (7 Replies)
Discussion started by: brsett
7 Replies

4. Shell Programming and Scripting

Capturing the output of dbv

Hello, We have an oracle database running on a Linux host (RHEL5)...I'm trying to run Oracle dbv (database verify utility) and capture its output to a file using the following syntax but the standart output does NOT get redirected to the file... dbv blocksize=32768 ... (2 Replies)
Discussion started by: luft
2 Replies

5. Shell Programming and Scripting

Capturing Sybase SP output in Shell Script

Greetings, I need to capture the output of a Sybase stored procedure, inside my shell script( k shell). Based on this output, I need to call another perl script, with input arguments as the result set of the procedure execution. I need to keep looping through and call the perl script, ... (2 Replies)
Discussion started by: rajpreetsidhu
2 Replies

6. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

7. Shell Programming and Scripting

Capturing the output from an exec command

Hi, I'm new to ksh - unix platform. I'm writing a small script which will search my current directory and will search for file names which it takes input from the users. Here is the code I'm having. 1 #!/bin/ksh 2 echo "enter a file name to be searched in the current dir : " 3 read... (1 Reply)
Discussion started by: avik
1 Replies

8. UNIX for Advanced & Expert Users

Capturing command prompt from a C/C++ program

Hello, I would like to capture the password request of a process (like passwd or smbpasswd, ...) from a C/c++ program. My idea was to use pipes, but they capture only the stdout/stdin, not the request itself (e.g. "Enter password for user tom:" is not captured by pipes). In other words, my... (1 Reply)
Discussion started by: mousec
1 Replies

9. Shell Programming and Scripting

capturing output in script

I have the following line in my script: $sftpcmd $rmthost <<COMMANDS>> $sftplog 2>&1 For some reason this is not capturing the errors from sftp, they go to the file attached to the cron entry ie mm hh dd MM * /myscript > cron.out any idea why? digital unix 4.0d (6 Replies)
Discussion started by: MizzGail
6 Replies

10. Programming

Capturing cli Program output

A few years ago I took a C programming class and used both Linux and FreeBSD as my operating systems and gcc as the compiler. I ran a Command-line utility to to capture what happened as I ran the code, the output was saved to a file that I specified when I ran the utility command (that I can't... (1 Reply)
Discussion started by: Christopher
1 Replies
Login or Register to Ask a Question