FAQ Database Discussion Community


How to send message through anonymous pipe in c

c,pipe
I try to use anonymous pipe to send two messages to the parent. I understand that I need to put the parent into the wait state to let children write the second message then read it from the pipe. I've tried to use wait(NULL) to let the parent wait for...

Delphi XE8: problems running an external console application, waiting for its results and capturing its results

delphi,pipe,console-application,createprocess,waitforsingleobject
In Delphi XE8 under Windows, I am trying to call an external console application and capture its output. I use the following code, as described in Capture the output from a DOS (command/console) Window and also Getting output from a shell/dos app into a Delphi app: procedure TForm1.Button1Click(Sender: TObject) ;...

How to detect whether the command output is being used in unix pipe

mysql,unix,command,pipe,output
In MySql -e option prints different formatting when used the output with pipe. Without Pipe [[email protected] commands]# $MYSQL_CONNECT_STR -e 'select 0/8' +--------+ | 0/8 | +--------+ | 0.0000 | +--------+ With Pipe -- no formatting. [[email protected] commands]# $MYSQL_CONNECT_STR -e 'select 0/8'| more 0/8 0.0000 How the mysql command detecting that...

Python Sh Library for MySQL dump import using output redirection (<) pipes

python,mysql,pipe,sh
I am using Python Sh (https://amoffat.github.io/sh/) and I was wondering if its possible to use <> pipes as well? Mainly I am talking about mysql < dump.sql. I was thinking about using mysql -D db -e "source mydump.sql' but source is not recommended for that. Is there any other options?...

Continuous data stream from linux command line into python script

python,linux,command-line,tcp,pipe
I need to get a continuous stream of data flowing from a peripheral device, to a raspberry pi, and lastly to my computer (mac). So far, the data is can make its way continuously (in real time) from the peripheral, to the command line of my raspberry pi. Note that...

close(pipe[1]) after exec

c,pipe,exec
I got a pipe. int anotherPipe[2]; make(anotherPipe); Both of the following processes have access to this pipe. Process A: close(anotherPipe[0]); dup2(anotherPipe[1], 1); //redirect stdout to pipe execl("/usr/bin/who", "usr/bin/who", NULL); close(anotherPipe[1]); //this is never executed Process B: close(anotherPipe[1]); read(anotherPipe[0], stringbuffer, bytestoread); printf("%s\n", buffer); printf("checkpoint\n"); close(anotherPipe[0]); The "who" command's output from execl...

piping a cat command to c++ code multiple times

c++,pipe,istream
If I want to read a file multiple times with the command ./run in.txt, there is a straight way... 0- ofstream fin; 1- while (fin >> i) {...} 2- fin.clear(); fin.seekg(0); 3- while (fin >> i) {...} However, I want to pipe a zipped input file to the program. The...

Unix - Pipe, forks, execlp, dup2, c program

c,linux,unix,pipe,fork
This is for an assignment. I am new to programming in unix and could use some help. I need to create a C program that does the following: In the main() function, it creates a pipe using the pipe() function, then creates two child processes with fork(). Child 1 redirects...

Why aren't programs affecting this pipe output?

bash,pipe
I'm passing the output of a command to sort, but the result I'm getting back isn't sorted: $ plushu logs foo | sort 2015-05-23T11:07:18.294569666Z Unhandled rejection RqlDriverError: First argument to `run` must be an open connection. 2015-05-23T11:07:18.294627441Z at new RqlDriverError (/app/node_modules/endex/node_modules/rethinkdb/errors.js:14:13) 2015-05-23T11:07:18.294632871Z at MakeArray.TermBase.run (/app/node_modules/endex/node_modules/rethinkdb/ast.js:129:29) 2015-05-23T11:07:18.294636744Z at /app/node_modules/endex/index.js:131:24...

bash: piping output from a loop seems to change the scope within the loop - why?

bash,loops,scope,pipe
I've noticed that variable scope within a bash for loop seems to change if I pipe the output of the loop. For example, here g remains changed after the loop: $ g=bing; for f in foo; do g=fing; echo g in loop: $g; done; echo g after $g; g in...

structure with pointer through FIFO pipe in C

c,arrays,pointers,pipe
I am trying to setup a FIFO pipe with one server and one client. client.c #include<stdio.h> #include<fcntl.h> #include<stdlib.h> #include<string.h> typedef struct buffer { int pid; char *buffer; } my_buffer; /* void removefifo() { unlink("fifo_server"); unlink("fifo_client"); } */ main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "usa: %s...

Parametrization of a pipe with a function

powershell,pipe
I'm discovering powershell with some joy and some frustation, and I'm currently hitting a wall with respect to my powershell abilities. I'd like to create a pipe function to summarize member types of a collection of objects. Without a function, the working code looks like this: get-process | foreach {...

Pipe Feeding Anomaly

bash,pipe,fifo
I have a gzipped file that I've split into 3 separate files: xaa, xab, xac. I make a fifo mkfifo p1 and reassemble the files by reading from it, also calculating a checksum and unzipping the file in a pipe: cat p1 p1 p1 | tee >(sha1sum > sha1sum_new.txt) |...

Simultaneous writing in a file using pipes in linux

c,linux,file,pipe,system-calls
I have a file names.txt Pop,Jack and a file surnames.txt Ioan,Gry. I need to obtain the following output, person.txt, Pop Ioan, Jack Gry. I must create two programs: First read from file names.txt and write in person.txt. Second read from surnames.txt and write in person.txt. I need to use pipes...

How do I cat a file piped from echo?

bash,unix,pipe,cat
I would expect this to print the contents of foobar.txt: echo "~/sandbox/foobar.txt" | cat But instead it just prints to the console: ~/sandbox/foobar.txt How can I cat the file contents instead of printing the filename? EDIT: Here's a non-contrived example of what I'm actually trying to do: echo $RESULT \...

Piping data from child to parent in nodejs

node.js,pipe,child-process
I have a nodejs parent process that starts up another nodejs child process. The child process executes some logic and then returns output to the parent. The output is large and I'm trying to use pipes to communicate, as suggested in documentation for child.send() method (which works fine BTW). I...

Segmentation fault 11 printing string from struct

c,string,struct,pipe,fork
This is the first time I've run into Segmentation fault 11 in C and I can't seem to wrap my head around what is actually going wrong. What I'm trying to do is write a few int values to a struct plus the file name from the command line (char...

Multiple pipes and processes

c,operating-system,pipe,fork,child-process
I am trying to communicate with children processes and make them sort a part of a list. My problem is children processes read everything but do nothing after it. int main(int argc, char *argv[]){ int i; int num_children; pid_t pid; num_children= 3; int fd[num_children][2]; //PIPES for (i=0; i<num_children; i++) {...

Order of opening named pipes causing possible race condition?

c,pipe,ipc,named-pipes
I am trying to create a very basic client server communication between two processes using IPC via named pipes. I have 2 pipes, namely fifo_client and fifo_server I have the following two classes fifoclient.c and fifoserver.c that has the following lines of code to open the two pipes. fifoclient.c int...

Pipe select-string variable into select-string

variables,powershell,search,pipe
I'm providing the user 2 dropdown lists (1. "Region" and 2. "Site"), the second list dependant/dynamic on the first list selection. When a "Region" item is selected, I'm doing a select-string to lookup a file which has all region/site information to return all lines which match the selected Region plus...

c++: Let user process write to LOCAL_SYSTEM named pipe - Custom Security Descriptor

c++,windows,winapi,pipe,authorization
I have a service running as LocalSystem which creates a Processes in the logged on users' session. Then the service creates a named pipe to which the client connects to read and write. According to https://msdn.microsoft.com/en-us/library/aa365600%28v=vs.85%29.aspx the client can only read from the pipe (It's No Admin, not the Creator,...

Maintaining a FIFO readable across different executions

linux,database,pipe,fifo
I've never used a named pipe before and recently realized that is just what I need. I'm running a program using gnu parallel which could produce tons (GB's to 1TB, hard to know right now) of output formatted for a data base on mySQL. I figured out that I can...

Windows Piping to a file from CMD

windows,cmd,pipe,notepad
Quick question that I couldn't find an answer to. When piping to a file as such: echo "hello" > hello.txt does this operation actually call notepad.exe on Windows, or is this a non application level file operation?...

java processbuilder ffmpeg pipe

java,ffmpeg,pipe,processbuilder
i try to run ffmpeg out java. here my code: String[] temp = {"ffmpeg\\ffmpeg.exe","-i","input_track.ac3","-threads","0","-af","volume=volume="0.0"dB","-acodec","pcm_s32le","-ac","6","-ar","48000","-f","wav","-","|","ffmpeg\\fdkaac","--ignorelength","-m","1","-o","ouput_track.aac","-"}; ProcessBuilder pb = new ProcessBuilder(temp); Process p = pb.start(); int ev = 0; if (p.waitFor() != 0) { ev = p.exitValue(); } i try the comand at windows cmd, here have a problem with "|" at...

Effect of closing descriptor for pipe

pipe,posix,file-descriptor
I have this piece of code which does the same work as ls -l | wc -l. main () { int i; int p[2]; pid_t ret; pipe (p); ret = fork (); if (ret == 0) { close (1); dup (p[1]); close (p[0]); execlp ("ls", "ls", "-l", (char *) 0);...

Why are my pipes fuzzy?

html,css,pipe
I am creating a sitemap, and for some reason on all browsers the different separation pipes have different fuzziness. Chrome: .header a { color: black; text-decoration: none; } .header li { display: inline-block; } .header li:after { content: "|"; margin: 5px; } <div class="header"> <ul> <li><a href="http://test.com">Mainpage</a></li> <li><a href="http://example.com">Handbook</a></li> <li><a...

redirect unnamed pipe output to log file in c

c,pipe,fork,dup2
i want to redirect the output of an unnamed pipe to an opened log file in c but i can't seem to make it happen, my code looks like this: close(fildes[1]); FILE * file = fopen(logfile, "w"); int fd = fileno(file); if (fd == -1) { bail_out(EXIT_FAILURE, strerror(errno)); } /*...

How do I redirect data from a pipe to another in c?

c,linux,pipe
I am trying to write from one process to the another using two separate pipes. In the following manner: child1 writes to parent (using pipe1) parent writes to child2 (using pipe2) I have no problems writing to the parent, but when I try to relay the data to child2, the...

Confusion with dup2(), exec() and pipes

c,unix,pipe,exec,dup2
I have been struggling to understand the concept involving the commands dup2(), exec() and pipes in conjunction. The thing I am trying to achieve: Pipe the output of a program X to the input of a program Y. Something basic like who | sort with a parent and 2 children,...

Will a process writing to a pipe block if the pipe is full?

c,winapi,pipe,createprocess
I'm currently diving into the Win32 API and writing myself a wrapper class for CreateProcess and CreatePipe. I was just wondering what will happen if a process that I opened writes too much output for the pipe buffer to hold. Will the process wait until I read from the other...

Pass a list of files to perl script via pipe

linux,perl,shell,pipe
I am having a problem where my perl script will fail upon having an input piped, but works fine when I just list all the file names individually. For reference, input of the perl script is read with while(<>). Example: script.pl file1.tag file2.tag file3.tag runs fine. But the following all...

Pipe in for loop breaks double quoted variables

batch-file,for-loop,pipe,environment-variables,double-quotes
Situation: Using batchscript to retrieve certain values from a JSON. I've got the following batchscript: @ECHO off ECHO Enter npo.nl program-url : SET url= SET /P url= :: http://www.npo.nl/buitenhof/03-05-2015/VPWON_1232766/POMS_VPRO_850040 for example SETLOCAL ENABLEDELAYEDEXPANSION FOR /F "tokens=6 delims=/" %%A IN ("%url%") DO ( FOR /F "delims=" %%B IN ('curl.exe -s http://e.omroep.nl/metadata/aflevering/%%A...

Opening a file in Python: bytes array converted to string?

python,tcp,pipe,bytearray
I have a text file with data such as b'\x00\x09\x00\xfe' This was piped into a text file from a TCP socket stream. Call this text file 'stream.txt'. I opened this file with the following code: f = open("stream.txt", "rb") bytes_read = f.read() When I open this file within another Python...

Specific pipe command in Ubuntu's shell handling in C

bash,shell,ubuntu,pipe
I'm trying to simulate a pipe behavior on Ubuntu's Terminal, for example the command: "echo hello | wc". Please assume I got the tokens from stdin, handled everything correctly and now These are the commands I "received" from the user who typed them in the shell for me to handle....

Multiple pipes in subprocess

python,pipe,subprocess,named-pipes
I am trying to use Sailfish, which takes multiple fastq files as arguments, in a ruffus pipeline. I execute Sailfish using the subprocess module in python, but <() in the subprocess call does not work even when I set shell=True. This is the command I want to execute using python:...

How to compose Python exe programs using pipes?

python,python-2.7,batch-file,command-line,pipe
Python newbie here. I created a Python program, msg.py, which outputs a message (Hello, World). I created a Python program, id.py, which reads input and outputs it. Using py2exe I created an executable of each of them: msg.exe and id.exe I created a DOS batch file, set PATH to the...

Creating non blocking pipes to child that does not block and can be reused

c++,pipe,exec,fork
I am trying to create a inter process communication bus using pipes. I can send messages to the client, and i can receive messages at the client. I also tried to create another pipe which goes the other way, child-> parent. However I need this communication to be non blocking...

Reading input from .exe and writing to a .exe for reading Chess engine commands

c++,pipe,exe,interaction
I am searching all day for an example c++ program which will use ready .exe file which has as an output strings and then waits for standart input and again prints outputs and so on and so forth. For example my c++ program will use standard output to write "uci"...

How can `time` control other processes trough a pipe?

time,pipe,sh
In the general case we have a command like P | Q | R which has the following semantics for the shell: Create a processes P, Q, R Bind the output of P to the input of Q Bind the output of Q to the input of R Bind the...

Why does grep give “Binary file (standard input) matches”?

c,file,api,io,pipe
#include <stdio.h> int main() { FILE* cmd = popen("grep Hello", "w"); fwrite("Hello\n", 6, 6, cmd); fwrite("Hillo\n", 6, 6, cmd); fwrite("Hello\n", 6, 6, cmd); pclose(cmd); } The program above outputs: Binary file (standard input) matches Why does grep give the message, and how to fix it?...

What does it mean when I get a huge exit status when closing a pipe in perl

perl,pipe
I run a script using a pipe my $pid = open (OUTPUT, "$my_script") || ""; if (! $pid) { die("error"); } while (<OUTPUT>) { print; } close (OUTPUT); my $exit_status = $?>>8; print "$exit_status"; Some times I get a long exit status: 72057594037927935 What does this mean? What could cause...

SIGINT signal gets dropped during write to a pipe

c++,pipe,signals
I have a program that dumps pcap data gathered using the libpcap to stdout using pcap_dump function, with stdout as the FILE *. There is a little bit of cleanup necessary on SIGINT, so I handle that with sigaction(). This works nicely when executed from a shell. However, this program...

Pipe behavior is erratic, not confident about implementation

c,pipe
I am learning about ipc in Linux and trying out pipes. I've set up two pipes between the parent and two child processes. While the data goes through the pipes, I get weird newlines. For instance, the output would sometimes have an extra newline or no newline entirely or even...

Linux how to pass date command's output as input for a python program as command line argument

python,linux,pipe,command-line-arguments
I am quite a newbie to Linux. I have a very simple Python script that accepts command line arguments and prints them. Now I just want to pass the date command's output as input to this Python script and print it. The Python script looks like this. import sys print...

bash permission denied: Can't echo to the stdin of a running process?

bash,unix,process,pipe,echo
I'm trying to echo a command to the stdin of a running process, thus: echo -en '<Hex Command>' | /proc/<pid>/fd/0 but I'm denied permission. I tried wrapping it within sudo sh -c but faced the same error. What am I doing wrong? Edit: As a follow up question, if I...

C++ Gnuplot pipe input from C++ defined variables

c++,pipe,gnuplot
I am using C++ to pipe commands to gnuplot using the following code: FILE *gnuplotPipe = popen("gnuplot -persist", "w"); // Open a pipe to gnuplot if (gnuplotPipe) { // If gnuplot is found fprintf(gnuplotPipe, "reset\n"); //gnuplot commands fprintf(gnuplotPipe, "n='500'\n"); fprintf(gnuplotPipe, "max='1500'\n"); fprintf(gnuplotPipe, "min='-1500\n"); fprintf(gnuplotPipe, "width=(max-min)/n\n"); fprintf(gnuplotPipe, "hist(x,width)=width*floor(x/width)+width/2.0\n"); fprintf(gnuplotPipe, "set term...

C++ character array not being read right through pipe

c++,arrays,pipe
I'm trying to check that the cmd variable is set to "LISTALL" but it isn't when I try printing it out. #include <stdio.h> #include <unistd.h> #include <cstring> #include <stdlib.h> #include <iostream> #include <sys/wait.h> int main(int argc, char **argv) { pid_t cPid = fork(); int P2C[2]; int C2P[2]; pipe(P2C); pipe(C2P); char...

C++ How to send and read an array through a pipe?

c++,arrays,pipe
I have a program which forks and I want the parent and the child process to communicate through an array of size 3, but I am not able to do this. Reading from the pipe meant to pass the array to the child process seems to always give the wrong...

How to pass url to wget

grep,pipe,wget
If I have a document with many links and I want to download especially one picture with the name: www.website.de/picture/example_2015-06-15.jpeg. How can I write a command that downloads me automatically exactly this one I extracted out of my document. My idea would be this but I'll get a failure message...

Crontab shell scripting PHP test

php,shell,pipe,crontab
Here is my script (autoRun.sh, and it is executable): date >> testResults.txt php DatabaseTest.php >> testResults.txt And here is my crontab file: 30 11 * * * /Users/myName/Desktop/autoRun.sh DatabaseTest.php and testResults.txt both exist on the desktop with autoRun.sh, but when I check my text file, nothing is in it and...

piping stockfish misbehaves in fedora

c++,pipe,virtual-machine,fedora
Somewhere in my project I use fork and pipe to execute another process and pipe its I/O to communicate with it (I'm writing it in C++). There is no problem when I compile it in Ubuntu 14.04, it will work just fine, but I compiled it in fedora on a...

C++ Pass a string into a pipe to gnuplot

c++,string,pipe,gnuplot
I'm having a small problem passing a string to gnuplot from c++ I can pass integers easily enough, but when I try a string (user defined as "title" earlier in the code): fprintf(gnuplotPipe, "set title %s\n", title); I get the error: error: cannot pass objects of non-trivially-copyable type ‘std::string {aka...

Why doesn't execlp allow me to use a pipe?

c,unix,pipe,exec
#include <stdio.h> #include <unistd.h> main() { execlp("ls" , "ls", "-l", "|" , "sort", NULL); } What's going wrong? Please help. If I write this: execlp("ls" , "ls", "-l", NULL); then the result displays on screen and if I try this execlp("ls" , "ls", "-l", "|" , "sort", NULL); screen displays...

Using Pipe for input and output on FFMPEG?

c#,ffmpeg,pipe
I want to use ffmpeg to convert video packets to mjpeg, and ideally, I want to pipe in the gob packet and receive the output via pipe also. I'm using a C# process to call ffmpeg like this: -f h264 -i pipe: -an -f mjpeg -q:v 1 pipe: I pipe...

Max number of open files per process in Linux

linux,pipe,limit,ulimit
I using the command: ulimit -n and i take the number 1024, which is the max number of open files per process in my system. But with the following programm i take the number 510...? What is wrong #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <errno.h> int main(...

Unzip the archive with more than one entry

linux,curl,zip,pipe,archive
I'm trying to decompress ~8GB .zip file piped from curl command. Everything I have tried is being interrupted at <1GB and returns a message: ... has more than one entry--rest ignored I've tried: funzip, gunzip, gzip -d, zcat, ... also with different arguments - all end up in the above...

C struct values garbled

c,pipe
Having the problem with the sender and receiver of the checksum. where I am using the struct to define the variables to be written into the pipe. struct ANSWER { int arr[BUFFER]; int counter; int ans; }a; The mechanism used for checksum is : int chck(int value[],int count) { int...

When piping, why do you have to close() the opposite end of a pipe before using dup2()?

c,pipe
In this code example, I noticed that you have to close the opposite end of a piped read buffer before writing to it, and vice versa. Why is that and what kind of consequences or side effects would there be if you didn't close the opposite end? int main() {...

Piping output of bash function

bash,shell,pipe
I'm trying to connect the inputs/outputs of two bash functions with a pipe. Here is a complete program which illustrates my issue: function print_info { files=$(ls); echo $files; } touch "file.pattern" print_info | grep "pattern" rm -f file.pattern But this simply outputs a list of all files, not those that...

In Bash, what happens when you pipe several asynchronous commands to one consumer?

bash,asynchronous,parallel-processing,pipe,buffer
Consider this Bash code: (cmd1 & cmd2) | consumer What possible things might consumer see on its standard input? output from cmd1, then output from cmd2? lines from cmd1 interspersed arbitrarily with lines from cmd2? bytes from cmd1 interspersed arbitrarily with bytes from cmd2? something else? ...

linux stdin, stdout pipe

linux,pipe,stdout,stdin
I have a brick.sprite. I have a executable in Debain 8 "Kali Linux" with this code: #include <stdio.h> #include <stdint.h> #include <iostream> /** * To use this file, pipe a sprite of the old format into stdin, and * redirect stdout to a second file of your chosing. The sprite...

How to output redirect to overwrite file while command is running Linux?

linux,pipe,output-redirect
I am not sure if this is even possible. But I am using this command to get network throughput. ifstat -t -S -i wlan0 Run just like that it updates inline on the console but when I pipe it, it appends a new line to the file. ifstat -t -S...

Why does using `execl` instead of `system` stops my program from working?

c,linux,unix,pipe,ipc
I'm trying to do basic IPC using pipes. I spent hours searching the internet, doing this and that, reading the API documentations, and ended up with the code below. But it does not work, as I quite expected. Just any help making my code 'work' would be many thanks. <edit>...

C pipes write/read priority

c,pipe,fork
I am trying to understand pipes and the use of fork in C. Below is an example of a code that calls fork() and then: Child process: Reads the pipe and prints the content to console. Parent process: Writes in the pipe "hello world". int main(void) { pid_t pid; int...

Multiple forks and IO:Pipe

perl,pipe
I am trying to build a program wich creates some forks and writes the results of the forks back to the main program. Thereby I try to use IO::Pipe sub ForkRequests { my $pipe = IO::Pipe->new(); my $pid; foreach my $feature ( @features ) { if ( $pid = fork()...

Batch script terminates in case of error when using pipe operator

batch-file,error-handling,pipe
I need to perferm error handling (check ERRORLEVEL) on an operation involving the pipe operator, but instead of the script continuing with a non-zero ERRORLEVEL, it terminates immediately. How can I avoid this behavior? Consider the following example. (Note that is a simplified constructed example to illustrate the problem -...

Crontab not piping to file (LINUX)

linux,pipe,crontab
The cronjob does not pipe the output from another script to a file but it works I execute it (not same user, chmod for both files is set to 777). #! /bin/sh . /disk2/etc/env_cron SUBJ="Test" TEXT=/disk2/home/user/mailtxt ADDR="[email protected]" echo -e `date` > $TEXT echo -e "1\n\n\nq" | menu >> $TEXT mutt...

Linux: Pipe `find` text file list | `dos2unix` | `dd` command

bash,pipe,ubuntu-14.04
What I'm attempting to do: Line 1: find any .txt or .TXT file and pipe them into next command Line 2: convert the .txt file to unix format (get rid of Windows line endings) Line 3: delete the last line of the file, which is always blank find "${TEMPDIR}" -name...

Syntax error with use of pipe in bash

bash,pipe,heredoc
I'm diving headfirst into bash with no prior experience and have hit a bit of a snag: I wrote a small bash script to determine the average of values (it's just a total right now) being returned by a c executable. #Sample value of #s1total: 0+0.000117+0.000149+0.000106 printf "\n%s" $s1total #The...

Pipe continuous stream to another command

awk,stream,pipe,tail
I wrote a program to analyze the log files in real time. I need to feed it with the IPs. It works fine with the command: cat /var/log/apache2/access.log | awk '{print $1}' | ./my_program Also, I can get the IPs in real time with the command: tail -f /var/log/apache2/access.log | awk '{print...

Interpreting STRACE output - pipes and forks

c,linux,pipe,fork,strace
I have the following code written in C, taken from http://beej.us/guide/bgipc/output/html/multipage/pipes.html: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int pfds[2]; pipe(pfds); if (!fork()) { close(1); /* close normal stdout */ dup(pfds[1]); /* make stdout same as pfds[1] */ close(pfds[0]); /* we don't need this */ execlp("/bin/ls", "ls", NULL);...

running a program through ssh fails with “Error opening terminal: unknown.”

linux,bash,parsing,ssh,pipe
When I try to execute a simple command through ssh, then it is successful. e.g. #] ssh servername "echo abcd" abcd #] However, when I try the following command, it fails: #] ssh servername ~/htopmem.sh Error opening terminal: unknown. #] where the content of htopmem.sh is below. (inspired by the...

InputStream from a pipe to another process remains blocked

java,pipe
I'm trying to do some basic piping in Java. I wrote a very simple program for testing, but the code keeps getting blocked in the while loop because there seems to be no input from stdout of cat. Which part did I do wrong? public static void main(String[] arguments) throws...

C: Trying to implement unnamed pipes

c,linux,bash,ubuntu,pipe
I'm trying to make a program that simlutates the terminal's nameless pipes. For example, if I want to run the command: ls –l | grep ‘10’ would be: ./pipes ls -l - grep '10' (I use - instead of |). However, my program doesn't work because execvp fails (bad adress)....

need help in plotting the most simple x,y graph using gnuplot through C pipes

c,pipe,gnuplot
i know gnu plot is quite a good tool and has many features, but i only need it to plot a simple X and Y graph with data values provided through the pipe from a C program here ,i have written a simple program to plot some value, it is...

pipe causing processes to freeze

c,pipe
The program report launches two accessed processes. Report basically feeds accessed a list of filenames and accessed prints if they have been accessed in x days. However, my implementation is causing accessed to freeze somehow. After running reports, nothing gets printed. When I run ps, I can see two accessed...

How do I silence the HEAD of a curl request while using the silent flag?

bash,shell,curl,command-line,pipe
When I run the curl command and direct the data to a file, I get back the content of the site as expected. $ curl "www.site.com" > file.txt $ head file.txt Top of site ... However, this command shows a progress bar, which I do not want: % Total %...

Bash scripting: permanent pipe

linux,bash,scripting,pipe,file-descriptor
Here is a script I tried to write: #!/bin/bash cat <&3 & # runs in background, takes input from file desc 3 echo "To Terminal" ... echo "To cat" 1>&3 echo "to cat again" 1>&3 Essentially I want my script to spawn a program (in this case, cat) and be...

How to write/read multiple times to a pipe

c,pipe,fork,ipc
I'm trying to make two child processes communicate with each other via pipe.First child have to write data 1 and data 2, and then second child writes data 3 and data 4. Then childrens read each other data and print them. This is the code that i have so far....

get standard output and error output in different files in C

c,pipe,output,ubuntu-12.04
I'm trying to solve a problem because I'm learning to use system calls in C. I used a Ubuntu 12.04 64bit. I have this statement: Implement a code that allows to redirect the standard out of the two commands deferred into a file (standard output) and all error output into...

fork and pipe confusion from quiz

c,linux,pipe,fork
This is a quiz from my class, and it invovles concept around fork and pipe. I just have a several confusions about this code. 1) What does if((pid = fork() == 0) means? is it just checking fork using pid(process id), why does loop start with this? 2)close (p[1]); what...

How to grep a string in a program?

c,linux,io,grep,pipe
#include <stdlib.h> int foo(char *str_buf_to_grep) { // How to write the following line correctly? return system("??? str_buf_to_grep ??? | grep mykeyword"); } Description: The str_buf_to_grep is given in any way, which might be the content of a text file, and might be very long and complex, even contains special characters,...

Dealing with pipes in C

c,linux,shell,pipe
I am trying to implement a shell in C language on Linux.This project that I am working on, asks to create a shell in C, starting from creating a very basic one (myShell), which goes deeper step by step.First I had to create a shell with simple commands like ls,pwd,echo,date,time...

Are UDP sockets on Windows falling back to pipes on the same machine?

sockets,winapi,udp,pipe
Not sure whether this is true or not, whether it is platform specific, nor whether if there's a standard that forces an implementation to abide by such a rule, hence the question: If one opens UDP sockets (WINAPI) to establish communication between processes on the same machine, will the communication...

How to implement pipes for multiple processes?

c,linux,unix,process,pipe
I am creating multiple processes and I need to create two unnamed pipes for each process. For each child, one pipe will be used to get int value from parent; one for sending to int arrays to parent. Parent will do some things while getting new data from childs. The...

using pipe while executing command through the parent

c,linux,pipe
I am to implement a nameless pipe, and I must execute the command in the parent process, not in any of his child. every "-" equals a call for a pipeline ("|"), also part of the assignment I have this code. can someone explain to me why it doesn't work?...

Is select() + non-blocking write() possible on a blocking pipe or socket?

sockets,unix,pipe,posix,blocking
The situation is that I have a blocking pipe or socket fd to which I want to write() without blocking, so I do a select() first, but that still doesn't guarantee that write() will not block. Here is the data I have gathered. Even if select() indicates that writing is...

Implementing unlimited piping in shell using C

c,linux,bash,shell,pipe
I'm trying to implement a C shell that allows for unlimited unidirectional pipes using the character '>' So it can handle ls -A > tail > grep '.zip' I understand that pipes are supposed to talk between processes, but I thought I came up with an idea that could use...

Application crashing on pclose

android,c,linux,file-io,pipe
I have an application that parses the output from a command line using popen. However, when tested on Android, it crashes on pclose: Why? When tested in other Unix environment I have no error... char commandLine[256] = "ps -A | grep -c myApplication"; FILE * fPipe = popen(commandLine, "r"); if...

Piping emails from postfix under Plesk to Ostickets helpdesk

bash,email,pipe,postfix-mta
I'm trying to pipe support emails from my production mail server (Plesk 12 and Postfix) to send them to another VPS hosting my helpdesk installation, I have chosen ostickets helpdesk for many reasons (Open source,PHP/MySQL...) So, the idea is to trigger email reception on some adresses such as [email protected], [email protected].....

Program stuck on Pipe (exec ls grep sort)

c,linux,pipe,fork,dup2
I'm trying to make a program that executes the following commands connecting the output of one to the input of the next using pipes and taking two arguments DIR (directory) and ARG (filetype, example: jpg). ls DIR -laR | grep ARG | sort Here's the code: int main(int argc, char...

Redirecting the output to a text file in MongoDB

linux,mongodb,ubuntu,pipe
I want to redirect the output of a mongodb command into a file, but it's not working. I searched a lot on the net, but none of the commands worked for me. > mongo --quiet 99.99.99.99/db --eval 'printjson(db.productAttribute.distinct('productId'))' > /home/myname/output_query.json Wed May 13 12:28:58.022 SyntaxError: Unexpected identifier > mongo --quiet...

pipe can not read/write all the chars

c++,linux,ubuntu,pipe,fork
I am trying to send array of char from one process to another using pipe, the characters are passing but not all of them! only the part of the beginning. This is my code: int p1[2], p2[2]; int main() { pipe(p1); int f1= fork(); if(f1 == 0) { char ar[100];...

C++ Fork child, ask child for process list, kill a process in Linux

c++,linux,pipe,fork
I'm trying to create a child process, send the child process a command "LISTALL". The child process should then issue the system the command ps and return that list to the parent process. The parent process should then choose a process and kill it. This is what I have so...

What is happening inside this regex alteration expression

regex,perl,pipe,strip
The following regular expresion works but can anyone explain how? Any comment is appreciated! Thanks! Quinoa What is the regex "|" doing to strip the tags "" and "" from <script>Keep THIS</Script> to get "Keep THIS" into memory $1? Here is the REGEX: (?x) ([\w\.!?,\s-])|<.*?>|. Here is the string: <script>Keep...

Does FIFO reserve message boudary?

unix,pipe,fifo,mkfifo
We know tcp doen't reserve message boundary but udp do. But what is the case with pipe and fifo? For example, Suppose we have a server and two clients on the same host, server creates a FIFO using a well known pathname, and open this FIFO for read. Client 1...

Pipes, child processes, and the scope of a child process

c,unix,concurrency,pipe,fork
I am in an Operating Systems class and I have a project that deals with forks and pipes. I'm trying to understand forks and pipes a little better before I get started on my project, so I was working through an example. This is the code in question (case 0...

How to pipe uncompressed file to a function's arguments

bash,pipe
I am trying to extract a .gz file and pass it to a function that converts it to a delimited file. The .gz contains a .grib2 file which I can convert to a csv using a utility called wgrib2. The problem is that I need to be able access the...

How to send a variable between two C programs

c,pipe,exec,fork,argument-passing
I have a C program, xyz.c which does some computations on a certain variable, say transferme. I want to transfer this variable/ pass this variable to another C program, say jkl.c. I have been trying to do the following: Fork the xyz.c and use execvp() to pass this transferme to...

Gulp task apply uglify if file in pipe is javascript

javascript,pipe,task,gulp
I want to check if the file in the pipe is .js or not (it could be .map, .html, ...). And if so, uglifying it before copying it in the correct path. ʕ •́؈•̀) I've try something like this (which not working): gulpfile.js gulp.src(current + '/**/*', {base: current}) .pipe($.tap(function (file)...