Search Results

Search found 134 results on 6 pages for 'piping'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • piping in UNIX doubt

    - by Happy Mittal
    In The Unix Programming Environment by K & P, it is written that " The programs in a pipeline actually run at the same time, not one after another. This means that programs in a pipeline can be interactive;" How can programs run at same time? For ex: $ who | grep mary | wc -l How grep mary will be executed until who is run or how wc -l will be executed until it knows results of previous programs?

    Read the article

  • cygwin GNU make .net program piping inconsistent behavior

    - by Codism
    This question may sound like a superuser question but I feel there is something related to programming. Anyway, my computer had a fresh installation of Win 7 64 and cygwin recently. Now I observed some problem with pipe handling in gnu make file. The following is the Makefile I use to reproduce the issue: all: fsutil | cat my-dotnet-console.exe | cat The problem is: for the first command line, the piping works every time but for the second command line, the piping barely works - I got no result for the second command for most cases, regardless of the environment (cmd or bash) in which the make file is invoked. However, if I copy paste the second command line into cmd (or bash), the pipe works every time. The following is my .net program: static void Main(string[] args) { Console.WriteLine(new string('a', 40)); Console.Out.Flush(); } The make version is 3.82.90 but the same problem was observed in a previous version (because of the windows path handling problem in 3.82.9, I replaced make.exe with a previous version). I don't know the exact cygwin version I have installed but the current version on cygwin.com is 1.7.11-1. Currently, my work around is to redirect the output to a temporary file but it would be great if I can avoid the temporary file. Thanks

    Read the article

  • PHP Library to read incoming emails (e.g email piping) [on hold]

    - by RickM
    I'm looking for an existing PHP library that can basically read a pop3 or smpt account, or accept piped mail and then read it, giving you the option to store it, or simply 'play with it' in PHP. I've been looking around for something but I have yet to see any sort of library that can be used for this. Has anyone here had any experience doing this, and are there any libraries available that can handle incoming mail? Thanks

    Read the article

  • "find" command and piping its output through another program

    - by Charbel
    this is not an Ubuntu specific quesion, it applies to all unix/linux. how can I run a command like this: find . -maxdepth 1 -type d -print -exec svn info "{}" | grep URL \; the command above doesn't do what I want, I can't seem to pipe the output of the svn info to grep. This works, but the output contains much more than I need: find . -maxdepth 1 -type d -print -exec svn info "{}" \; Any ideas?

    Read the article

  • Piping stream into tar on FreeBSD

    - by Casey Jordan
    I am trying to pipe a tar/gzip archive into tar to decompress it. The script I have is part of a self extracting installer, where my archive is appended to the script. This works fine on linux, and the script looks like this: export TMPDIR=`mktemp -d /tmp/selfextract.XXXXXX` echo "TEMP: $TMPDIR" ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0` tail -n+$ARCHIVE $0 | tar xz -C $TMPDIR exit 0 __ARCHIVE_BELOW__ The tar archive as a string is after the ARCHIVE_BELOW but I omitted it from here since it's huge. However, when I do this on FreeBSD I get the following error: tar: Failed to open '/dev/sa0' I read that this is because free BSD expects to read from that device by default and you can tell it to read from stdin by passing -f - like so: tail -n+$ARCHIVE $0 | tar zxf - -C $TMPDIR However, when I do this I just get the error: tar: Damaged tar archive tar: Retrying... Can anyone point out what I am doing wrong here? I need to do it this way (Via piping) for efficiency reasons. Thanks

    Read the article

  • Mail not piping in postfix

    - by user220912
    I have setup a postfix server and wanted to test the piping of mail to my perl script where i can make use of it and filter the mails.I wrote a test script for that which just logs the information in txt file. but i don't see any changes on sending the mail. My postconf-n output: alias_database = hash:/etc/aliases append_dot_mydomain = no command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 html_directory = no inet_interfaces = all inet_protocols = all mail_owner = postfix mailbox_size_limit = 0 mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = yantratech.co.in, localhost.localdomain, localhost myhostname = tcmailer8.in mynetworks = 103.8.128.62, 103.8.128.69/101, 168.100.189.0/28, 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 myorigin = $mydomain newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES recipient_delimiter = + relayhost = sample_directory = /usr/share/doc/postfix-2.6.6/samples sendmail_path = /usr/sbin/sendmail.postfix smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) smtpd_tls_cert_file = /etc/pki/tls/certs/tcmailer8.in.cert smtpd_tls_key_file = /etc/pki/tls/private/localhost.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_use_tls = yes transport_maps = hash:/etc/postfix/transport virtual_alias_maps = hash:/etc/postfix/virtual virtual_gid_maps = static:5000 virtual_mailbox_base = /home/vmail virtual_mailbox_domains = /etc/postfix/vhosts virtual_mailbox_maps = hash:/etc/postfix/vmaps virtual_minimum_uid = 1000 virtual_uid_maps = static:5000 here's my transport: [email protected] email_route my main.cf declaration: transport_maps = hash:/etc/postfix/transport my master.cf declaration: email_route unix - n n - - pipe flags=FR user=nobody argv=/etc/postfix/test.php -f $(sender) -- $(recipient) and my php script: #!/usr/bin/php <?php $fh = fopen('/etc/postfix/testmail.txt','a'); fwrite($fh, "Hello it works\n"); fclose($fh); ?> I am sending mails through telnet in localhost.

    Read the article

  • Trouble with piping through sed

    - by Joel
    I am having trouble piping through sed. Once I have piped output to sed, I cannot pipe the output of sed elsewhere. wget -r -nv http://127.0.0.1:3000/test.html Outputs: 2010-03-12 04:41:48 URL:http://127.0.0.1:3000/test.html [99/99] -> "127.0.0.1:3000/test.html" [1] 2010-03-12 04:41:48 URL:http://127.0.0.1:3000/robots.txt [83/83] -> "127.0.0.1:3000/robots.txt" [1] 2010-03-12 04:41:48 URL:http://127.0.0.1:3000/shop [22818/22818] -> "127.0.0.1:3000/shop.29" [1] I pipe the output through sed to get a clean list of URLs: wget -r -nv http://127.0.0.1:3000/test.html 2>&1 | grep --line-buffered -v ERROR | sed 's/^.*URL:\([^ ]*\).*/\1/g' Outputs: http://127.0.0.1:3000/test.html http://127.0.0.1:3000/robots.txt http://127.0.0.1:3000/shop I would like to then dump the output to file, so I do this: wget -r -nv http://127.0.0.1:3000/test.html 2>&1 | grep --line-buffered -v ERROR | sed 's/^.*URL:\([^ ]*\).*/\1/g' > /tmp/DUMP_FILE I interrupt the process after a few seconds and check the file, yet it is empty. Interesting, the following yields no output (same as above, but piping sed output through cat): wget -r -nv http://127.0.0.1:3000/test.html 2>&1 | grep --line-buffered -v ERROR | sed 's/^.*URL:\([^ ]*\).*/\1/g' | cat Why can I not pipe the output of sed to another program like cat?

    Read the article

  • Piping perfmon logs over DFS

    - by Sal
    I'm running perfmon on several servers, and I'd like all of the output to be piped to one particular server. I'm trying to do this over DFS by modifying the Root directory arg on each of the servers and placing a DFS path like so: Root Directory: \\PERFMON_LOG_REPOSITORY\[MY_COMP_NAME] The trouble is that when I make the Root directory dump the logs to a file over DFS, I always get the following error upon starting up the Collector Set: when attempting to start the data collector set the following system error occurred: access is denied

    Read the article

  • Process ANSI escape codes before piping

    - by Tiddo
    I'm trying to pipe the output of a script (Mocha) to another script. However there is one problem: Mocha generates quite a few ansi escape characters to update the screen on the fly. These characters are also send through the pipe. Is there a way to process the ansi sequence such that the output is the same as the final output to the screen? I do want to keep color escape sequences, but not the curser movement escapes. Edit: I have a partial solution now (for Mocha only): so far it seems that Mocha with the spec output (the one I use) only generates color ecape characters and the CSI 0G escape sequence. The CSI 0G escape character means that the cursor should move back to the beginning of the line. Mocha uses this to overwrite a line completely. Therefore you could simply create a sed regexp which will delete everything up to that escape sequence on a line: sed 's/^.*\x1b\[0G//g'. I am still looking for the complete solution though.

    Read the article

  • "Piping" to MPD

    - by oxinabox.ucc.asn.au
    I would like to "Pipe" the output of my local sound card to MPD on a networked music server. Anyone have any suggestions how to go about this? I'm thinking maybe i can make a live MP3 stream? maybe over the web, or over the intranet? (IIRC MPD supported MP3 streams, i've had Internet radio steams going (though I didn't set them up) I'm not very experienced with MPD, or with webcasts

    Read the article

  • Piping Mail with Exim: Only Works Locally

    - by John
    Whenever I send an email to my catchall alias via SSH (i.e., locally), Exim successfully pipes the e-mail to a PHP script, as I told it to do. However, when I try to send an e-mail to my catchall alias via my e-mail client (i.e., remotely), Exim won't pipe the e-mail. Any ideas?

    Read the article

  • Piping powershell messages to Write-EventLog

    - by Richard
    I have a powershell script that runs a custom cmdlet. It is run by Task Scheduler and I want to log what it does. This is my current crude version: Add-PsSnapIn PianolaCmdlets Write-EventLog -LogName "Windows Powershell" -Source "Powershell" -Message "Starting Update-EbuNumbers" -EventId 0 Get-ClubMembers -HasTemporaryEbuNumber -show all | Update-EbuNumbers -Verbose Write-EventLog -LogName "Windows Powershell" -Source "Powershell" -Message "Finished Update-EbuNumbers" -EventId 0 What I would like to do is log the output of my custom cmdlet. Ideally I'd like to create different types of event log entries based on whether it was a warning or a verbose message. Update: I don't want to log the return value of the commandlet. The Update-EbuMembers cmdlet does not return an object. I want to log any verbose messages written by WriteVerbose and I want to log errors created by ThrowTerminatingError.

    Read the article

  • Mutual piping on linux

    - by user21919
    I would like the output of A to be input for B and at the same time the output of B to be the input for A, is that possible? I tried the naïve thing: creating named pipes for A (pipeA) and B (pipeB) and then: pipeB | A | pipeA & pipeA | B | pipeB & But that does not work (pipeB is empty and switching the order would not help either). Any help would be appreciated. Example: Command A could be compiled form of this C program: #include <stdio.h> int main() { printf("0\n"); int x = 0; while (scanf("%d", &x) != EOF) { printf("%d\n", x + 1); } return 0; } Command B could be compiled form of this C program: #include <stdio.h> int main() { int x = 0; while (scanf("%d", &x) != EOF) { printf("%d\n", x + x); } return 0; }

    Read the article

  • Piping the output of a program to Preview.app

    - by Abhay Buch
    I'm using an application (the dot program of the graphviz library) that generates a wide variety of file formats including PostScript and PDF. It can send the result to stdout or to a file. I'm currently sending it to a file and opening it with Preview. Is there any way to pipe the output and have it be read by Preview, so that I'd don't have to generate a file and have it lying around? This is going to be used by a number of people who won't know the internal structure of the generating script and I don't want to clutter their folders or complicate their lives. More generally, is there any way to take a program that sends its output to stdout and pass that output to an program that usually takes it's input from a file, without actually creating a file?

    Read the article

  • Syntax for piping varnish logs to rotatelogs

    - by jetboy
    Ubuntu 12.04 Server x64, Varnish 3.0.2 I'm trying to pipe varnishncsa's logs through Apache's rotatelogs, and running from the shell, things work fine: sudo varnishncsa -a -P /var/run/varnishncsa/varnishncsa.pid |/usr/sbin/rotatelogs /var/log/varnish/varnish.log.%Y%m%d%H 3600 creates a new logfile in /var/log/varnish, with rotation every hour (3600 seconds). However, I'm struggling to get things working the same way inside /etc/init.d/varnishncsa: PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/$NAME PIDFILE=/var/run/$NAME/$NAME.pid LOGFILE=/var/log/varnish/varnishncsa.log USER=varnishlog DAEMON_OPTS="-a -P ${PIDFILE}" DAEMON_PIPE="|/usr/sbin/rotatelogs /var/log/varnish/varnish.log.%Y%m%d%H 3600" ... start_varnishncsa() { output=$(/bin/tempfile -s.varnish) log_daemon_msg "Starting $DESC" "$NAME" create_pid_directory if start-stop-daemon --start --verbose --pidfile ${PIDFILE} \ --chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} \ > ${output} 2>&1; then log_end_msg 0 else log_end_msg 1 cat $output exit 1 fi rm $output } Where should I put DAEMON_PIPE in the above code? I've tried at the end of: if start-stop-daemon --start --verbose --pidfile ${PIDFILE} which is where additional command line parameters usually go, but it isn't creating a logfile.

    Read the article

  • Piping Objects From Format-Table to Export-CSV Has Unexpected Results

    - by makerofthings7
    I'm running this command to get a list of all Activesync users and export them to C:\activesync.csv Get-ActiveSyncDevice | Get-ActiveSyncDeviceStatistics | sort-object status, devicetype , lastsyncattempttime | ft FirstSyncTime ,LastPolicyUpdateTime ,LastSyncAttemptTime ,LastSuccessSync , DeviceType , DeviceID, DeviceAccessState, Identity -a | Export-Csv c:\activesync.csv The problem is that the CSV data doesn't match the console display if I omit the trailing | c:\activesync.csv ... where the data and columns displayed don't match. Is this a bug in powershell?

    Read the article

  • Bash alias with piping

    - by n8felton
    I'm not exactly sure what I'm doing wrong with this one. I'm trying to run the command alias localip='ip -4 -o addr show eth0 | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' | head -n 1' If I run the command ip -4 -o addr show eth0 | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' | head -n 1 I get the result I expect, however, when trying to create an alias with the command, I get -bash: syntax error near unexpected token `(' Any help would be appreciated. TIA.

    Read the article

  • Supporting Piping (A Useful Hello World)

    - by blastthisinferno
    I am trying to write a collection of simple C++ programs that follow the basic Unix philosophy by: Make each program do one thing well. Expect the output of every program to become the input to another, as yet unknown, program. I'm having an issue trying to get the output of one to be the input of the other, and getting the output of one be the input of a separate instance of itself. Very briefly, I have a program add which takes arguments and spits out the summation. I want to be able to pipe the output to another add instance. ./add 1 2 | ./add 3 4 That should yield 6 but currently yields 10. I've encountered two problems: The cin waits for user input from the console. I don't want this, and haven't been able to find a simple example showing a the use of standard input stream without querying the user in the console. If someone knows of an example please let me know. I can't figure out how to use standard input while supporting piping. Currently, it appears it does not work. If I issue the command ./add 1 2 | ./add 3 4 it results in 7. The relevant code is below: add.cpp snippet // ... COMMAND LINE PROCESSING ... std::vector<double> numbers = multi.getValue(); // using TCLAP for command line parsing if (numbers.size() > 0) { double sum = numbers[0]; double arg; for (int i=1; i < numbers.size(); i++) { arg = numbers[i]; sum += arg; } std::cout << sum << std::endl; } else { double input; // right now this is test code while I try and get standard input streaming working as expected while (std::cin) { std::cin >> input; std::cout << input << std::endl; } } // ... MORE IRRELEVANT CODE ... So, I guess my question(s) is does anyone see what is incorrect with this code in order to support piping standard input? Are there some well known (or hidden) resources that explain clearly how to implement an example application supporting the basic Unix philosophy? @Chris Lutz I've changed the code to what's below. The problem where cin still waits for user input on the console, and doesn't just take from the standard input passed from the pipe. Am I missing something trivial for handling this? I haven't tried Greg Hewgill's answer yet, but don't see how that would help since the issue is still with cin. // ... COMMAND LINE PROCESSING ... std::vector<double> numbers = multi.getValue(); // using TCLAP for command line parsing double sum = numbers[0]; double arg; for (int i=1; i < numbers.size(); i++) { arg = numbers[i]; sum += arg; } // right now this is test code while I try and get standard input streaming working as expected while (std::cin) { std::cin >> arg; std::cout << arg << std::endl; } std::cout << sum << std::endl; // ... MORE IRRELEVANT CODE ...

    Read the article

  • Difference between piping a file to sh and calling a shell file

    - by Peter Coulton
    This is what was trying to do: $ wget -qO- www.example.com/script.sh | sh which quietly downloads the script and prints it to stdout which is then piped to sh. This unfortunately doesn't quite work, failing to wait for user input a various points, aswell as a few syntax errors. This is what actually works: $ wget -qOscript www.example.com/script.sh && chmod +x ./script && ./script But what's the difference? I'm thinking maybe piping the file doesn't execute the file, but rather executes each line individually, but I'm new to this kind of thing so I don't know.

    Read the article

  • Run shell script using fabric and piping script text to shell's stdin

    - by Peter Lyons
    Is there a way to execute a multi-line shell script by piping it to the remote shell's standard input in fabric? Or must I always write it to the remote filesystem, then run it, then delete it? I like sending to stdin as it avoids the temporary file. If there's no fabric API (and it seems like there is not based on my research), presumably I can just use the ssh module directly. Basically I wish fabric.api.run was not limited to a 1-line command that gets passed to the shell as a command line argument, but instead would take a full multi-line script and write it to the remote shell's standard input.

    Read the article

  • Pipe implementation

    - by nunos
    I am trying to implement a linux shell that supports piping. I have already done simple commands, commands running in background, redirections, but piping is still missing. I have already read about it and seen some snippets of code, but still haven't been able to sort out a working solution. What I have so far: int fd[2]; pid_t pid = fork(); if (pid == -1) return -1; if (pid == 0) { dup2(0, fd[0]); execlp("sort", "sort", NULL); } I am a novice programmer, as you can probably tell, and when I am programming something I don't know much about, this being obviously the case, I like to start with something really easy and concrete and then build from there. So, before being able to implement three and more different commands in pipeline, I would like to be able to compute "ls names.txt | sort" or something similiar, in which names.txt is a file of names alfabetically unordered. Thanks.

    Read the article

  • problem with piping in my own implementation of shell

    - by codemax
    Hey guys, i am implementing my own shell. I want to involve piping. i searched here and i got a code. But it is not working.Can any one help me? this is my code #include <sys/types.h> #include <sys/wait.h> #include <sys/ipc.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <iostream> #include <cstdlib> using namespace std; char temp1[81][81],temp2[81][81] ,*cmdptr1[40], *cmdptr2[40]; void process(char**,int); int arg_count, count; int arg_cnt[2]; int pip,tok; char input[81]; int fds[2]; void process( char* cmd[])//, int arg_count ) { pid_t pid; pid = fork(); //char path[81]; //getcwd(path,81); //strcat(path,"/"); //strcat(path,cmd[0]); if(pid < 0) { cout << "Fork Failed" << endl; exit(-1); } else if( pid == 0 ) { execvp( cmd[0] , cmd ); } else { wait(NULL); } } void pipe(char **cmd1, char**cmd2) { cout<<endl<<endl<<"in pipe"<<endl; for(int i=0 ; i<arg_cnt[0] ; i++) { cout<<cmdptr1[i]<<" "; } cout<<endl; for(int i=0 ; i<arg_cnt[1] ; i++) { cout<<cmdptr2[i]<<" "; } pipe(fds); if (fork() == 0 ) { dup2(fds[1], 1); close(fds[0]); close(fds[1]); process(cmd1); } if (fork() == 0) { dup2(fds[0], 0); close(fds[0]); close(fds[1]); process(cmd2); } close(fds[0]); close(fds[1]); wait(NULL); } void pipecommand(char** cmd1, char** cmd2) { cout<<endl<<endl; for(int i=0 ; i<arg_cnt[0] ; i++) { cout<<cmd1[i]<<" "; } cout<<endl; for(int i=0 ; i<arg_cnt[1] ; i++) { cout<<cmd2[i]<<" "; } int fds[2]; // file descriptors pipe(fds); // child process #1 if (fork() == 0) { // Reassign stdin to fds[0] end of pipe. dup2(fds[0], STDIN_FILENO); close(fds[1]); close(fds[0]); process(cmd2); // child process #2 if (fork() == 0) { // Reassign stdout to fds[1] end of pipe. dup2(fds[1], STDOUT_FILENO); close(fds[0]); close(fds[1]); // Execute the first command. process(cmd1); } wait(NULL); } close(fds[1]); close(fds[0]); wait(NULL); } void splitcommand1() { tok++; int k,done=0,no=0; arg_count = 0; for(int i=count ; input[i] != '\0' ; i++) { k=0; while(1) { count++; if(input[i] == ' ') { break; } if((input[i] == '\0')) { done = 1; break; } if(input[i] == '|') { pip = 1; done = 1; break; } temp1[arg_count][k++] = input[i++]; } temp1[arg_count][k++] = '\0'; arg_count++; if(done == 1) { break; } } for(int i=0 ; i<arg_count ; i++) { cmdptr1[i] = temp1[i]; } arg_cnt[tok] = arg_count; } void splitcommand2() { tok++; cout<<"count is :"<<count<<endl; int k,done=0,no=0; arg_count = 0; for(int i=count ; input[i] != '\0' ; i++) { k=0; while(1) { count++; if(input[i] == ' ') { break; } if((input[i] == '\0')) { done = 1; break; } if(input[i] == '|') { pip = 1; done = 1; cout<<"PIP"; break; } temp2[arg_count][k++] = input[i++]; } temp2[arg_count][k++] = '\0'; arg_count++; if(done == 1) { break; } } for(int i=0 ; i<arg_count ; i++) { cmdptr2[i] = temp2[i]; } arg_cnt[tok] = arg_count; } int main() { cout<<endl<<endl<<"Welcome to unique shell !!!!!!!!!!!"<<endl; tok=-1; while(1) { cout<<endl<<"***********UNIQUE**********"<<endl; cin.getline(input,81); count = 0,pip=0; splitcommand1(); if(pip == 1) { count++; splitcommand2(); } cout<<endl<<endl; if(strcmp(cmdptr1[0], "exit") == 0 ) { cout<<endl<<"EXITING UNIQUE SHELL"<<endl; exit(0); } //cout<<endl<<"Arg count is :"<<arg_count<<endl; if(pip == 1) { cout<<endl<<endl<<"in main :"; for(int i=0 ; i<arg_cnt[0] ; i++) { cout<<cmdptr1[i]<<" "; } cout<<endl; for(int i=0 ; i<arg_cnt[1] ; i++) { cout<<cmdptr2[i]<<" "; } pipe(cmdptr1, cmdptr2); } else { process (cmdptr1);//,arg_count); } } } I know it is not well coded. But try to help me :(

    Read the article

  • Piping to findstr's input

    - by Gauthier
    I have a text file with a list of macro names (one per line). My final goal is to get a print of how many times the macro's name appears in the files of the current directory. The macro's names are in C:\temp\macros.txt. type C:\temp\macros.txt in the command prompt prints the list alright. Now I want to pipe that output to the standard input of findstr. type C:\temp\macros.txt | findstr *.ss (ss is the file type where I am looking for the macro names). This does not seem to work, I get no result (very fast, it does not seem to try at all). findstr <the first row of the macro list> *.ss does work. I also tried findstr *.ss < c:\temp\macros.txt with no success.

    Read the article

1 2 3 4 5 6  | Next Page >