Search Results

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

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

  • piping findstr's output

    - by Gauthier
    Windows command line, I want to search a file for all rows starting with: # NNN "<file>.inc" where NNN is a number and <file> any string. I want to use findstr, because I cannot require that the users of the script install ack. Here is the expression I came up with: >findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*.inc" all_pre.txt The file to search is all_pre.txt. So far so good. Now I want to pipe that to another command, say for example more. >findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9]*.inc" all_pre.txt | more The result of this is the same output as the previous command, but with the file name as prefix for every row (all_pre.txt). Then comes: FINDSTR: cannot open | FINDSTR: cannot open more Why doesn't the pipe work? snip of the content of all_pre.txt # 1 "main.ss" # 7 "main.ss" # 11 "main.ss" # 52 "main.ss" # 1 "Build_flags.inc" # 7 "Build_flags.inc" # 11 "Build_flags.inc" # 20 "Build_flags.inc"

    Read the article

  • Piping input to a Java app with Perl

    - by user319479
    I need to write a Perl script that pipes input into a Java program. This is related to this, but that didn't help me. My issue is that the Java app doesn't get the print statements until I close the handle. What I found online was that $| needs to be set to something greater than 0, in which case newline characters will flush the buffer. This still doesn't work. This is the script: #! /usr/bin/perl -w use strict; use File::Basename; $|=1; open(TP, "| java -jar test.jar") or die "fail"; sleep(2); print TP "this is test 1\n"; print TP "this is test 2\n"; print "tests printed, waiting 5s\n"; sleep(5); print "wait over. closing handle...\n"; close TP; print "closed.\n"; print "sleeping for 5s...\n"; sleep(5); print "script finished!\n"; exit And here is a sample Java app: import java.util.Scanner; public class test{ public static void main( String[] args ){ Scanner sc = new Scanner( System.in ); int crashcount = 0; while( true ){ try{ String input = sc.nextLine(); System.out.println( ":: INPUT: " + input ); if( "bananas".equals(input) ){ break; } } catch( Exception e ){ System.out.println( ":: EXCEPTION: " + e.toString() ); crashcount++; if( crashcount == 5 ){ System.out.println( ":: Looks like stdin is broke" ); break; } } } System.out.println( ":: IT'S OVER!" ); return; } } The Java app should respond to receiving the test prints immediately, but it doesn't until the close statement in the Perl script. What am I doing wrong? Note: the fix can only be in the Perl script. The Java app can't be changed. Also, File::Basename is there because I'm using it in the real script.

    Read the article

  • Piping a bash variable into awk and storing the output

    - by Andrew Smith
    Hello, To illustrate my problem, TEST="Hi my name is John" OUTP=`echo $TEST | awk '{print $3}'` echo $OUTP What I would expect this to do is pass the $TEST variable into awk and store the 3rd word into $OUTP. Instead I get "Hi: not found", as if it is expecting the input to be a file. If I pass just a string instead of a variable, however, there is no problem. What would be the best way to approach this? Thanks all!

    Read the article

  • Piping SoX in Python - subprocess alternative?

    - by Cochise Ruhulessin
    I use SoX in an application. The application uses it to apply various operations on audiofiles, such as trimming. This works fine: from subprocess import Popen, PIPE kwargs = {'stdin': PIPE, 'stdout': PIPE, 'stderr': PIPE} pipe = Popen(['sox','-t','mp3','-', 'test.mp3','trim','0','15'], **kwargs) output, errors = pipe.communicate(input=open('test.mp3','rb').read()) if errors: raise RuntimeError(errors) This will cause problems on large files hower, since read() loads the complete file to memory; which is slow and may cause the pipes' buffer to overflow. A workaround exists: from subprocess import Popen, PIPE import tempfile import uuid import shutil import os kwargs = {'stdin': PIPE, 'stdout': PIPE, 'stderr': PIPE} tmp = os.path.join(tempfile.gettempdir(), uuid.uuid1().hex + '.mp3') pipe = Popen(['sox','test.mp3', tmp,'trim','0','15'], **kwargs) output, errors = pipe.communicate() if errors: raise RuntimeError(errors) shutil.copy2(tmp, 'test.mp3') os.remove(tmp) So the question stands as follows: Are there any alternatives to this approach, aside from writing a Python extension to the Sox C API?

    Read the article

  • Unix Piping using Fork and Dup

    - by Jacob
    Lets say within my program I want to execute two child processes, one to to execute a "ls -al" command and then pipe that into "wc" command and display the output on the terminal. How can I do this using pipe file descriptors so far the code I have written: An example would be greatly helpful int main(int argc, char *argv[]) { int pipefd[2] pipe(pipefd2); if ((fork()) == 0) { dup2(pipefd2[1],STDOUT_FILENO); close(pipefd2[0]); close(pipefd2[1]); execl("ls", "ls","-al", NULL); exit(EXIT_FAILURE); } if ((fork()) == 0){ dup2(pipefd2[0],STDIN_FILENO); close(pipefd2[0]); close(pipefd2[1]); execl("/usr/bin/wc","wc",NULL); exit(EXIT_FAILURE); } close(pipefd[0]); close(pipefd[1]); close(pipefd2[0]); close(pipefd2[1]); }

    Read the article

  • Piping to findstr's input, dos prompt

    - 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 dos 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

  • Why Does Piping Binary Text to the Screen often Horck a Terminal

    - by Alan Storm
    Imaginary Situation: You’ve used mysqldump to create a backup of a mysql database. This database has columns that are blobs. That means your “text” dump files contains both strings and binary data (binary data stored as strings?) If you cat this file to the screen $ cat dump.mysql you’ll often get unexpected results. The terminal will start beeping, and then the output finishes scrolling by you’ll often have garbage chacters entered on your terminal as through you’d typed them, and sometimes your prompts and anything you type will be garbage characters. Why does this happen? Put another way, I think I’m looking for an overview of what’s actually happening when you store binary strings into a file, and when you cat those files, and when the results of the cat are reported to the terminal, and any other steps I’m missing.

    Read the article

  • linux piping ( convert -> pdf2ps -> lp)

    - by Bor
    Ok, so I can print a pdf doing: pdf2ps file.pdf - | lp -s But now I want to use convert to merge several pdf files, I can do this with: convert file1.pdf file2.pdf merged.pdf which merges file1.pdf and file2.pdf into merged.pdf, target can be replaced with '-'. Question How could I pipe convert into pdf2ps and then into lp though?

    Read the article

  • Force line-buffering of stdout when piping to tee

    - by houbysoft
    Usually, stdout is line-buffered. In other words, as long as your printf argument ends with a newline, you can expect the line to be printed instantly. This does not appear to hold when using a pipe to redirect to tee. I have a C++ program, a, that outputs strings, always \n-terminated, to stdout. When it is run by itself (./a), everything prints correctly and at the right time, as expected. However, if I pipe it to tee (./a | tee output.txt), it doesn't print anything until it quits, which defeats the purpose of using tee. I know that I could fix it by adding a fflush(stdout) after each printing operation in the C++ program. But is there a cleaner, easier way? Is there a command I can run, for example, that would force stdout to be line-buffered, even when using a pipe?

    Read the article

  • Piping EOF problems with stdio and C++/Python

    - by yeus
    I got some problems with EOF and stdio. I have no idea what I am doing wrong. When I see an EOF in my program I clear the stdin and next round I try to read in a new line. The problem is: for some reason the getline function immediatly (from the second run always, the first works just as intended) returns an EOF instead of waiting for a new input from py python process... Any idea? alright Here is the code: #include <string> #include <iostream> #include <iomanip> #include <limits> using namespace std; int main(int argc, char **argv) { for (;;) { string buf; if (getline(cin,buf)) { if (buf=="q") break; /*****///do some stuff with input //my actual filter program cout<<buf; /*****/ } else { if ((cin.rdstate() & istream::eofbit)!=0)cout<<"eofbit"<<endl; if ((cin.rdstate() & istream::failbit)!=0)cout<<"failbit"<<endl; if ((cin.rdstate() & istream::badbit)!=0)cout<<"badbit"<<endl; if ((cin.rdstate() & istream::goodbit)!=0)cout<<"goodbit"<<endl; cin.clear(); cin.ignore(numeric_limits<streamsize>::max()); //break;//I am not using break, because I //want more input when the parent //process puts data into stdin; } } return 0; } and in python: from subprocess import Popen, PIPE import os from time import sleep proc=Popen(os.getcwd()+"/Pipingtest",stdout=PIPE,stdin=PIPE,stderr=PIPE); while(1): sleep(0.5) print proc.communicate("1 1 1") print "running"

    Read the article

  • Awk appears to disconnect my DB2 session when piping

    - by greggannicott
    Hello. I'm attempting to run the following command in Korn Shell (ksh): set -A INDEXES `db2 "describe indexes for table ${TABSCHEMA}.${TABNAME} show detail" | awk '{print $1"."$2}'` What I'm attempting to achieve is place a list of the indexes over a particular table into an array which I can later iterate through. The problem is, when I run the above command the contents of the array starts with the error message of 'SQL1024N' (which is telling me that the database connection does not exist). However, if I remove the 'awk' at the end of the statement as so: set -A INDEXES `db2 "describe indexes for table ${TABSCHEMA}.${TABNAME} show detail"` it works just fine (well, to the extent its returning data. Obviously without the awk I'm not capturing the correct data). Does anyone know why the awk is having this affect? I appreciate there is more than one way to get this data, but it baffles me as to why this is happening. Thanks in advance. Greg.

    Read the article

  • problems piping in node.js

    - by alvaizq
    We have the following example in node.js var http = require('http'); http.createServer(function(request, response) { var proxy = http.createClient(8083, '127.0.0.1') var proxy_request = proxy.request(request.method, request.url, request.headers); proxy_request.on('response', function (proxy_response) { proxy_response.pipe(response); response.writeHead(proxy_response.statusCode, proxy_response.headers); }); setTimeout(function(){ request.pipe(proxy_request); },3000); }).listen(8081, '127.0.0.1'); The example listen to a request in 127.0.0.1:8081 and sends it to a dummy server (always return 200 OK status code) in 127.0.0.1:8083. The problem is in the pipe among the input stream (readable) and output stream (writable) when we have a async module before (in this case the setTimeOut timing). The pipe doesn't work and nothing is sent to dummy server in 8083 port. Maybe, when we have a async call (in this case the setTimeOut) before the pipe call, the inputstream change to a state "not readable", and after the async call the pipe doesn't send anything. This is just an example...we test it with more async modules from node.js community with the same result (ldapjs, etc)... We try to fix it with: - request.readable =true; //before pipe call - request.pipe(proxy_request, {end : false}); with the same result (the pipe doesn't work). Can anybody help us? Many thanks in advanced and best regards,

    Read the article

  • piping to variables

    - by lego69
    cut -d" " -f2 ${2} | $callsTo hello, can somebody please explain can I pipe the result of cut to variable callsTo, and how will it be stored, as the string or list?

    Read the article

  • Can piping of screen to file change the result of a C++ code?

    - by Biga
    I am having this very weird behaviour with a C++ code: It gives me different results when running with and without piping the screen to a file (reproducible in cygwin and linux). I mean, if I get the same executable and run it like './run' or run it like './run out.log', I get different results! I use std::cout to output to screen, all lines ending with endl; I use ifstream for the input file; I use ofstream for output, all lines ending with endl. I am using g++ 4. Any idea what is going on? UPDATE: I have hard-coded the input data, so 'ifstream' is not used, and problem persists. UPDATE 2: That's getting interesting. I have output three variables that are computed initially, and that's what I get with and without piping direct to screen: 0 -0.02 0 piped: 0 -0.02 1.04083e-17 So there's a round-off difference with and without piping the output! Now, why piping would interefere with an internal computation of the code?

    Read the article

  • Combining echo and cat on Unix

    - by Dan
    Really simple question, how do I combine echo and cat in the shell, I'm trying to write the contents of a file into another file with a prepended string? If /tmp/file looks like this: this is a test I want to run this: echo "PREPENDED STRING" cat /tmp/file | sed 's/test/test2/g' > /tmp/result so that /tmp/result looks like this: PREPENDED STRINGthis is a test2 Thanks.

    Read the article

  • how install minimum domain email piping to script in centos?

    - by Adam Ramadhan
    hello i have search google on a simple tutorial on how to make a piping email. first how does really email technically work? "stmp is a process that binds to 25, waiting for email request that goes in from another stmp process(in another server) determined by the domain MX route that will send the message to port 25 if any email goes though the MX.domain.tld" that is in a nutshell how emailing work, am i right? or there is something wrong here? second, so if im right, we need to set a SMTP server so we can receive incoming emails from MX SMTP route right? ive googled though google and found two best STMP servers from my opinion, they are EXIM and POSTFIX, can anybody give us a simple tutorial installing and setting up an email piping for a fresh installed linux/centos? example *.domain.tld -> allinonepipe.php thanks.

    Read the article

  • Why is piping dd through gzip so much faster than a direct copy?

    - by Foo Bar
    I wanted to backup a path from a computer in my network to another computer in the same network over a 100MBit/s line. For this I did dd if=/local/path of=/remote/path/in/local/network/backup.img which gave me a very low network transfer speed of something about 50 to 100 kB/s, which would have taken forever. So I stopped it and decided to try gzipping it on the fly to make it much smaller so that the amount to transfer is less. So I did dd if=/local/folder | gzip > /remote/path/in/local/network/backup.img.gz But now I get something like 1 MB/s network transfer speed, so a factor of 10 to 20 faster. After noticing this, I tested this on several paths and files and it was always the same. Why does piping dd through gzip also increase the transfer rates by a large factor instead of only reducing the bytelength of the stream by a large factor? I'd expected even a small decrease in transfer rates instead, due to the higher CPU consumption while compressing, but now I get a double plus. Not that I'm not happy, but just wondering. ;)

    Read the article

  • Is there any fundamental difference between piping in mac and linux?

    - by Mohammad Moghimi
    ps -e | grep bash sample output from a linux machine: 1128 pts/14 00:00:00 bash 7491 pts/7 00:00:00 bash 12651 pts/14 00:00:00 bash 16145 pts/2 00:00:00 bash sample output from a mac machine: 58352 ttys000 0:00.09 login -pfl username /bin/bash -c exec -la bash /bin/bash 58353 ttys000 0:00.02 -bash 58390 ttys000 0:00.00 grep bash 20372 ttys005 0:00.06 login -pfl username /bin/bash -c exec -la bash /bin/bash 20373 ttys005 0:00.18 -bash My question is that why we see "grep bash" in the second case but not the first case.

    Read the article

  • I/O redirection using cygwin and mingw

    - by KLee1
    I have written a program in C and have compiled it using MinGW. When I try to run that program in Cygwin, it seems to behave normally (i.e. prints correct output etc.) However, I'm trying to pipe output to a program so that I can parse information from the program's output. However, the piping does not seem to be working in that I am not getting any input into the second program. I have confirmed this by using the following commands: This command seems to work fine: ./prog Performing this command returns nothing: ./prog | cat This command verifies the first: ./prog | wc Which returns: 0 0 0 I know that the script (including the piping from the program) works perfectly fine in an all Linux environment. Does anyone have any idea for why the piping isn't working in Cygwin? Thanks!

    Read the article

  • "tar -cfz" versus "tar cf - | gzip": are they different? (or how to improve a backup)

    - by I'm Dario
    I want to speed up my backup done with "tar -cfz", the common way to do it. But day by day my backed up files grow so it becomes slower. I was thinking to take advantage of the several cores available in my server and I was wondering if there is any difference between doing the backup with "tar -cfz" or piping tar to gzip ("tar cf - | gzip"). I guess that there isn't any difference, because the first spawns two processes (tar and gzip), in a similar way like piping it. If there is not difference, do you know any good alternative to do this, without going incremental? I'm looking at pigz too and it looks fine.

    Read the article

  • Welcome to the new home of the Plumber's Mate

    - by John Breakwell
    If you are a fan of my MSDN technical blog about (in the main) MSMQ then you've come to the right place. Additionally, If you've arrived here through searching the Internet for answers on MSMQ problems then you're in luck too. Should you be after some copper piping and a U-bend then you are going to be greatly disappointed ... unless I get a lot of such requests and decide that the IT business is not for me.

    Read the article

  • Postfix won't pipe to PHP file through aliases file

    - by jfreak53
    I'm trying to pipe from postfix to a command. According to Postfix logs it worked, but when I check the command it didn't. This is a fresh postfix install. This is my alias file: # See man 5 aliases for format postmaster: root support: "| /usr/bin/php -q /var/www/pipe/pipe.php" I run sendmail [email protected] then type it and then on a separate line type . and it goes. I check the postfix log /var/log/mail.log and this is what it states: Nov 2 15:32:33 server3 postfix/local[13284]: 42C429E0B5: to=<[email protected]>, relay=local, delay=156, delays=156/0.01/0/0.05, dsn=2.0.0, status=sent (delivered to command: /usr/bin/php -q /var/www/pipe/pipe.php) So according to that it worked, but it doesn't. If I run echo 'text' | /usr/bin/php -q /var/www/pipe/pipe.php it does work just fine. Any ideas what I did wrong? I know piping is working, I originally checked it by running that command above WITHOUT the quotes, so just support: | /usr/bin/php -q /var/www/pipe/pipe.php What it did there was append my email header and all to the file pipe.php. So I know postfix was piping it, but when I put in the quotes it says it's going but it's not according to my script.

    Read the article

  • Problem with apostrophes and other special characters when using aspell in windows

    - by Loftx
    Hi there, We seem to be having a problem with the spell checker on our content management system where it marks the ve part of We’ve as a misspelling. The spellchecker uses aspell which is called from a script on the server which executes the cmd.exe and uses it to pipe a file into aspell (it's a long winded way I know, but our server side programming langauge (ColdFusion) doesn't support writing to stdin for executables). Aspell is called by executing: c:\windows\system32\cmd.exe /c type d:\path_to_file\file.txt | "C:\Program Files\Aspell\bin\aspell" --lang=en -a Where file.txt contains the text to be spelled e.g. ^Oh have We’ve (the carat is added to prevent piping problems I believe). Aspell then output: @(#) International Ispell Version 3.1.20 (but really Aspell 0.50.3) * * * & ve 62 12: vie, voe, V, v, veg, vet, Be, Ce, be, Ev, E, e, vex, VA, VI, Va, Vi, vi, we, VD, VF, VG, VJ, VP, VT, Vt, vb, vs, DE, De, Fe, GE, Ge, He, IE, Le, ME, Me, NE, Ne, OE, PE, Re, SE, Se, Te, Xe, he, me, re, ye, Ave, Eve, Ive, ave, eve, VAR, var, veer, vier, view, vow However, we have a dev site, with the same version of Aspell, and when the same file is used it outputs with no misspellings. Both servers are running Aspell 0.50.3 on Windows server 2003, but there could be other differences in configuration: @(#) International Ispell Version 3.1.20 (but really Aspell 0.50.3) I'm wondering if the problem is to do with the piping part of the process or something different in the Aspell configuration. Does anyone have any ideas? Cheers, Tom

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >