pipe

How do I transfer wget output to a file or DB?

廉价感情. 提交于 2019-12-25 11:26:56
问题 I'm trying to use a small script to download a field from multiple pages. For one thing, I'm only able to get it from one page..., but the real problem I'm having is that I don't know how to hand the output off to a database table? How can I take the output from curl/lynx|grep (which is going to be all the list items) and move it, list item by list item, to a table in my DB or to a CSV where it will be ready for import to the DB? #!/bin/bash lynx --source "http://www.thewebsite.com"|cut -d\"

Timing of Makefile “include” statements for auto-generated files

时光总嘲笑我的痴心妄想 提交于 2019-12-25 09:45:54
问题 In this Makefile... all: piped.mk ifeq ($(PIPED),1) @echo Output of make is piped else @echo Output of make is NOT piped endif piped.mk: [ -t 1 ] && PIPED=0 || PIPED=1 ; echo "PIPED=$${PIPED}" > piped.mk .PHONY: piped.mk all include piped.mk ...I would expect the following: The first rule, all , says it depends on the file piped.mk . The file piped.mk is generated by asking the shell whether the terminal's stdout is a TTY or not The file piped.mk is include d at the end; in theory therefore

Redirect stdin and stdout in child in c

99封情书 提交于 2019-12-25 09:29:42
问题 I need to create a client-server app (using sockets), the basic idea is: client sends string server receives string and sends it as stdin of another app server reads stdout of the app server sends answer to client. The "other app" is a closed source calc (a calculator which reads from stdin the sort of 4 5 + and prints 9 ). I'm trying to create a double pipe on the server, fork, and use this pipes to redirect stdin and stdout of the calc: if(!fork()) { close(STDOUT_FILENO); close(STDIN_FILENO

LAMP: How to create .Zip from remote URLs/files and stream it to the client on the fly

烂漫一生 提交于 2019-12-25 09:01:42
问题 With external services like S3 for object storage, the old problem of providing custom zip archives of stored files gets a bit more complicated. One way would be for a web server to copy all the resources to temporary local files, compile them into a .zip, then return the zip to the user, but this is slow and resource intensive. Can this be done similarly to the solution for local files? e.g. can you curl the files, pipe them into zip in streaming mode, then out to the user on the fly? 回答1:

Problem migrating ConnectNamedPipe() from XP to Win 7

▼魔方 西西 提交于 2019-12-25 08:38:04
问题 We developed an XP application that uses ConnectNamedPipe() in blocking mode. When testing on Win 7, the application behaves as if it is unblocked: ConnectNamedPipe() returns before its VBS client connects. An exception is raised ("Waiting for a process to open the other end of pipe") when calling StreamReader.ReadLine(). When running with the debugger, this does not occur even in Win 7! These are the functions that we are using: [ DllImport("kernel32.dll", SetLastError = true)] public static

bash redirecting stdin to script

99封情书 提交于 2019-12-25 06:58:13
问题 I went through some bash i/o tutorials but most of them concern redirecting stream to/from files. My problem is the following: how to redirect stdin/stdout/stderr to script (or program). For instance I have script "parentScript.sh". In that script I want to call blackbox "childScript.sh" which takes few arguments -arg1 -arg2 ... and reads input from stdin. My goal is to feed childScript.sh with some input inside parentScript.sh: ... childScript.sh -arg1 -arg2 ????? < "input1" ????? < "input2"

How do i append some text to pipe without temporary file

廉价感情. 提交于 2019-12-25 06:57:32
问题 I am trying to get the max version number from a directory where i have several versions of one program for example if output of ls is something01_1.sh something02_0.1.2.sh something02_0.1.sh something02_1.1.sh something02_1.2.sh something02_2.0.sh something02_2.1.sh something02_2.3.sh something02_3.1.2.sh something.sh I am getting the max version number with the following - ls somedir | grep some_prefix | cut -d '_' -f2 | sort -t '.' -k1 -r | head -n 1 Now if at the same time i want to check

Capturing tshark standard output with popen in C

自古美人都是妖i 提交于 2019-12-25 06:48:16
问题 I'm trying to capture the standard output from tshark through a program in C. For that, I use popen() call to open tshark process and read from the returned FILE stream. Code sample: #include <stdio.h> #include <stdlib.h> int main() { FILE* pipe_fd = popen("tshark -i eth0 -R icmp -2 -T fields -e icmp.checksum -e icmp.seq", "r"); //FILE* pipe_fd = popen("lsof", "r"); if (!pipe_fd) { fprintf(stderr, "popen failed.\n"); return EXIT_FAILURE; } char buffer[2048]; while (NULL != fgets(buffer,

Windows Batch script to redirect stdout to stdin of an EXE we've just run

五迷三道 提交于 2019-12-25 03:45:08
问题 I know the normal behaviour when running an EXE in a batch script is for the batch script to wait for the EXE to exit before continuing, but is there any way to get the batch script to continue execution, but redirect its stdout to the stdin of the EXE? Basically I'm trying to achieve this neat trick or something similar... @ECHO OFF echo This is a windows batch script... dir /p C:\ C:\cygwin\bash.exe <--- Do some magic here echo This is a bash shell script... ls -la /cygdrive/c/ exit echo We

Piping to More Than One Location - PowerScript

穿精又带淫゛_ 提交于 2019-12-25 03:44:16
问题 I want to do something like this- "Error array cleared." | Out-File $ErrorLog $InfoLog -Append However it's not working. Is this possible without writing another line to output it to the other file? 回答1: One way is with a short function like this: function Out-FileMulti { param( [String[]] $filePath ) process { $text = $_ $filePath | foreach-object { $text | out-file $_ -append } } } Example: "Out-FileMultiTest" | Out-FileMulti "test1.log","test2.log" (Writes the string "Out-FileMultiTest" to