Ubuntu :: Redirecting Output From Printf Statement In C Program

May 22, 2010

I've got a C program that I've added some 'printf' statements to monitor a couple of variables. When I run this program manually or from a script, the output is displayed on screen. However, I need to change various variables in the 'test.c' file, run 'make clean' and 'make' a few hundred thousand times. I'm using a script to read the variables in and then using sed to do in-place edits of the file. Unfortunately, with this amount of iteration, it is getting rather tired!

Anyway, I've created a script that is working as long I respond to prompts. I've tried the following to no avail: Code: /path/to/script > /tmp/output /path/to/script > /tmp/output 2>&1 /path/to/script | tee (no output even after adding the -a option) In my C program, I have the following 'printf' statement: Code: printf ("variable1: $s variable2: $s",var1,var2); What am I missing? I've worked with redirection before and it's always worked out fine, but this one plain stumps!

View 2 Replies


ADVERTISEMENT

General :: Redirecting Output Of Set -x?

Mar 16, 2011

I have written a script and included the command

Code:
set -x
to see what happening when i run the script

View 7 Replies View Related

Ubuntu :: BASH Script: Odd Output Near IF Statement?

May 31, 2010

For some reason, I get said block of errors when I run my script without arguments:

Code:
/home/mark/bin/backup: line 34: [: =: unary operator expected
/home/mark/bin/backup: line 37: [: =: unary operator expected

[code].....

View 5 Replies View Related

Hardware :: Redirecting ALL Audio Output?

Jan 15, 2011

So I have a DAC/Headphone Amplifier which plugs in through USB. Through the system settings I'm able to set it as the preferred audio output option. This makes all the windows manager sounds come through the headphones, but all the applications still come through the laptop speakers; i guess they are completely independent of the system settings. I have to set each application's output preferences separately, and some software (like Firefox) doesn't have any output preferences. So is there a way toirect the audio output of all applications to all come through the USB DAC

View 4 Replies View Related

General :: Redirecting Output From Stderr?

Dec 1, 2010

I have seen a post where someone was explaining the virtuality of stdout and stderr and that it can be redirected with e.g. 2>file.txt but this apparently is not working for me!
I have a CUPS filter with fprintf(stderr,...)

View 5 Replies View Related

Ubuntu Multimedia :: Redirecting Pulseaudio Output Without Padevchooser

Jul 30, 2011

Today I tried to use padevchooser on Natty to send my laptop audio to my home media machine (which has the good speakers) using the "default server" option. Turns out padevchooser doesn't work on Unity and the threads I have seen say it is deprecated for other gui tools,

So what is the easy gui way to switch from my local pulse server to another one on my LAN, without using padevchooser, or switching off Unity? Or is this a regression?

View 2 Replies View Related

General :: Redirecting Command Output To File?

Sep 19, 2011

This seems so simple when doing it from command line but I'm not able to accomplish it inside a script. I am trying to put output of following command into a text file:

CMD= mysql -uroot -psecret -e 'SHOW SLAVE STATUS G;'
FIL=~/replication-`date +%F`.txt
MAILTEXT=~/mailtext.txt
touch $FIL
$CMD > $FIL

Where FIL is a variable that contains path of the file to which to output command. I am running this command in a shell script from where I want to email contents of $FIL as attachment using mutt. But I am always getting 0 byte file. Also if I examine in directory the file is of 0 byte length.

View 3 Replies View Related

General :: Redirecting Output From A Command Using Bash?

May 10, 2011

I would like to get the command and it's output redirected i have tried using the below but my syntax seems to be incorrect .

<<EOF
$(ls)
EOF

View 2 Replies View Related

Server :: Redirecting Output Of 'sendmail -bv' To Console?

May 3, 2011

When I run 'sendmail -bv', it sends the mail delivery status report as a mail to the root. Is there a way I can redirect this to the console instead of sending as a mail. requirement is to programatically find the mail host of the recipient for which I thought of using this 'sendmail -bv' command. Is there any other better way to find mail host of the recipient

View 12 Replies View Related

General :: Redirecting Output Message While Inserting A New Device?

Dec 28, 2010

When inserting/removing a usb device to a board based on linux system, an output is given:

Code:
# mmc1: card 0001 removed
mmc1: new SD card at address 0001

[code]...

View 6 Replies View Related

Programming :: Redirecting The Output Of Child Process To New Xterm?

Aug 2, 2010

I am developing a application. In this I fork() 3 childs(lets say child1 , child2, child3) . The parent is now waiting for some input from keyboard.Child3 is continously getting data from child1 and child2 using pipe which it then will print using printf.Now as the parent is waiting for input from user through keyboard while child3 is continously printing the data. I want to do it in different terminals.Can you please guide me how to proceed ahead so that on one terminal , the parent waits for input fromser while on other terminal child3 prints data.

View 1 Replies View Related

General :: Message In Terminal After Redirecting Output And Build Completes?

Oct 9, 2010

I'm not sure about the following behavior so thought I would put it out to see if there is an error I need to resolve, or simply a process that I need explained.I'm also not sure if this is an Ubuntu issue, a Linux issue, or other... but here goes.I ran my "make build" in two different ways; one with just "make build" and one with "make build > output" (so I could review the full script).With just "make build" the process finished and returned to the command prompt.

With "make build > output", after the process had finished (script in output document identical to what was in the terminal with "make build") a new set of data was displayed in the terminal (see below).With the other examples of using "make build > output" the times it would parse something back to the terminal window was when there was an error. As I fixed the errors these breaks back to the terminal window would stop. So I'm wondering if this indicates a new error, but because the "make build" now completes successfully (at least it appears to), I'm wondering if this data in the terminal window is just a behavior related to redirecting the output script using the ">" process and something to do with returning to the terminal once a process completes

View 4 Replies View Related

Programming :: Awk: Print Out A Message To The Screen When Redirecting The Output To File?

Mar 15, 2010

I have a problem when using awk:

e.g: awk '{processing text}' File1 > File2

But when I'm processing the File1, I want to print out some messages to the screen (not the File2). How can I do that?

View 5 Replies View Related

Networking :: Disabled Printing Statement In The Middle Of CPP Program Execution?

Jan 25, 2011

In my program(C++), I have a ping function call which will ping the specified IP and returns the result. The problem is, my code does not print the o/p to the terminal window after calling the ping fucntion for the first time. but, the cout statements exist before the ping function call, works fine. When i debug it using strace i found that output filedescriptor is getting closed some where through close(1), before returning from ping call. What would be the issue, can u please some one explains me what the problem is.

View 1 Replies View Related

Programming :: Redirecting Stdin / Stdout And Stderr For Program Run As Fork()/execl()?

Nov 24, 2010

I'm trying to write a program that will fork a series of FTP sessions. For each session, there should be separate input and output files associated with stdin and stdout/stderr.
I keep reading how I should be able to do that with dup2() in the child process before the execl(), but it's not working for me. Could someone please explain what I've done wrong? The program also has a 30-second sniper alarm for testing and killing of FTPs that go dormant for too long.

The code: (ftpmon.c)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

[code]....

The output:

$ ftpmon
Connected to gila-crstest.gilacorp.com (172.16.20.8).
220 (vsFTPd 2.0.1)
ftp> waitpid(): Interrupted system call

Why am I getting the ftp> prompt? If the dup2() works, shouldn't it be taking input from my script and not my terminal? In stead, it does nothing, and winds up getting killed after 30 seconds. The log file is created, but it's empty after the run.

View 3 Replies View Related

Programming :: Shell Script For Adding A Statement In A File After A Particular Statement?

Jun 28, 2010

We are building our C++ project in Kdevelop IDE. Every time we run "Run Configure" from the "Build" menu, a file named "libtool" gets automatically generated. This file contains a statement as "ECHO="echo"".f we run "Automake", without modifying the "libtool" the system hangs and theputer needs to be restarted.Therefore every time we run "Run Configure" we need to include the line "echo="echo"" below the statement "ECHO="echo"" manually.I think a script can be written which does the above on its own.I am not a shell script programmer, I know the good tutorials for shell scripts are available on the net, but learning scripting only for this task would be time-consuming and painful.

View 4 Replies View Related

General :: Redirecting Command Output To Input Of Another Command?

Jul 2, 2011

I want to run gsettings list-schemas (which return a list of about 100 names separated by spaces)and somehow direct each name one at a time as the input to this command:gsettings list-recursivelyI've tried it with awk, and standard | piping and also as a string variable strvar=$(gsettings list-schemas) and using the $strvar as the input butam missing something in between I'm sure like for - while or proper syntax of awk etc

View 3 Replies View Related

General :: Getting Back To "stdin" After Redirecting A File To A Particular Program?

Nov 22, 2010

I need to achieve a particular effect using bash's redirection facilities.I know that I can redirect a file to some program's standard input:[user@host]$ application < file.txtThe thing is, I'd like to know can I regain control of this program's input after the file content's have been passed to it. In other words, I'd like to run a command similar to the above, and then, instead of the termination of the application, I'd want it to wait for further commands from standard input (keyboard).

As I write this question, it occured to me that I could probably write another application (or a script), that would at first write some data to standard output and then act as echo, like:[user@host]$ stdin_proxy.sh | applicationWould it work, and is there any better way to do so? There are a bunch of Googleable tutorials covering this issue, but they all amount to one advice - "reopen the stdin after the file contents have been read".

View 1 Replies View Related

Programming :: Perl Switch Statement Throwing Error Like Bad Case Statement (invalid Case Value)?

Oct 6, 2010

I've written a simple perl code to learn switches in perl.My code is pasted below,

#!/usr/bin/perl
$opt = 1;
switch($opt) {

[code]...

View 3 Replies View Related

Ubuntu :: Make A Program Output To Serial?

Nov 29, 2010

I've made a LED gadget, which can light up LED patterns. It connects to serial port with RS232 protocol and receives messages which contain desired patterns. My friend wrote a python program which generates patterns and writes them to terminal. Everything is fine this far. I've made a bash script to run this program:

#!/bin/bash
python gen.py

and set it to autostart with:

chmod 755 scr.sh
mv scr.sh /etc/init.d/scr.sh
sudo update-rc.d scr.sh defaults

What I don't understand is - how do I redirect it's output to ttyS0 so that my device could catch generated data?

I've heard that in Linux every data stream can be redirected anywhere with '>>' in bash script. How do I do that? Can I, dunno, write something like this: python gen.py >> ttyS0 in shell script?

View 1 Replies View Related

Ubuntu :: Way To Select Which Output Device Program Uses?

Jan 8, 2011

Is there any way to select which output device a program uses? I notice many Ubuntu programs lack the choice to choose where the sound is outputted, for example Rhythmbox and Exaile.I have 3 sound outputs (Internal, PCI, HDMI) connected and I'd like to for example use the PCI card as default audio device but play music from Rhythmbox through the internal motherboard output.

View 2 Replies View Related

Ubuntu :: Defining Variables With Printf?

Mar 24, 2010

I am trying to use bash 'printf' to format an environment variable.Doing this I get on the screen just the format I need (underscores mean blank spaces):prompt> printf "%10s" "1.23"________1.23Unfortunately, when this is assigned to a variable, the format disappears:prompt> X=`printf "%10s" "1.23"`prompt> echo $X1.23Does anyone know what can be done in this case to get a proper format?Why does not 'printf' respect the left blank spaces when assigning values to a variable?

View 3 Replies View Related

Programming :: Output Of The C Program?

Jun 8, 2009

See the first program below :

Code:

This code when compiled gives the following errors:

1. conflicting types for 'fun' at line no: 9

2. previous declaration of 'fun' was here at line no: 3

Why is this happening?

If i modify the above program as shown in the second program below:

Code:

This code when compiled gives no errors.

Why the difference occurs between the first and second program?

View 8 Replies View Related

General :: Unexpected Output From Program?

Sep 8, 2010

while doing socket/network programming, i am getting SSH-2.0-openssh4.7 error, instead of showing day time of server.general description i have Linux Box, with the help of putty i am connecting from windows system to Linux box,no problem in loging,after typing program, i am running the program with gcc. when typing ./a.out, it is showing SSH-2.0-openssh4.7, actually it should display daytime from linux box in both tcp and udp.

View 1 Replies View Related

Software :: Use Touchscreen Output In C Program?

Apr 29, 2011

i use touch screen monitor .when some one touch on screen i want to wake up in my c program and i use this touch usb output for my prograam

View 1 Replies View Related

General :: Program To Visualize Anything That Goes Through My Audio-output?

Jun 1, 2011

I'm looking for a program that will visualize anything that goes through my audio-output (in this case it's Spotify) and display it on the screen. Does this exist?

I'm running Ubuntu.

View 1 Replies View Related

General :: Assign A Variable To The Output Value Of A Program?

Feb 6, 2011

so i wrote myself a very simple hellworld program in c++

...the usual stuff
int main()
{

[code]...

View 3 Replies View Related

Software :: Match Pid Value In Ps Output To Threads In Program?

Jul 20, 2010

I have a multithreaded program running. The threads are created by using pthread_create(). The ps shows a pid value for each thread in the process. The name of the thread is all the same as the parent process. I want to match the PID values in the ps output to the threads in my program. But when I used getpid() in each thread, the value I get is different from what ps shows. How do I match the pid value in ps output to the threads in my program.

View 1 Replies View Related

Programming :: C Program To Get Input Of Array And Output It

Aug 14, 2010

I am creating a 15 integer array which is input from the user and outputted for the.

Ex.
Enter the array values: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Your values are: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Code:

View 4 Replies View Related

Programming :: No Output To Log File From Daemon Program?

Mar 18, 2011

I am learning Linux daemon programming and write a simple daemon program. The issue is no data is written to the log file (/var/tmp/simpledeamon.log) though the file is successfully created (it's file size is zero from ls -l output). Could someone kindly point out the error in my program,The code is based on the Devin Watson's article at Here is the code:

// simplydaemon.cpp
// A simple Linux daemon.
#include <sys/types.h>

[code]...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved