How do I capture multiple lines of the status output of a command?
I need to know what the upload speed of an Internet connection. I thought the easiest way to do this would be to transfer a file via FTP to my server using the command:
Note: My environment allows me to issue ONLY 1 line of code. That line of code can have multiple commands seperated by a semi-colon( ; ).
The above command works great in terminal. It uploads the file and gives me lots of text to tell me what is going on:
Quote:
230 User username logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
250 CWD command successful.
local: file_to_be_uploaded remote: file_to_be_uploaded
502 'EPSV': command not understood.
227 Entering Passive Mode (69,13,207,4,232,153)
150 Opening BINARY mode data connection for .
100% |*************************************| 905 KB 200.51 KB/s 00:00 ETA
226 Transfer complete.
927204 bytes sent in 00:05 (173.23 KB/s)
I'm after that last line in the form:
x bytes sent in mm:ss (y KB/s)
I want to obtain the value for y. I thought the way to do this would be to send the output to a text file:
Problem is, all I get in ftpupload.txt is a previous line that has some useless error on it:
Quote:
502 'EPSV': command not understood.
How can I get the contents of the last line so I know what the upload throughput is?
Hi there!
I'm trying to write a script that will capture output from a command and assign it to a variable.
Let's say, for example, I'd like to catch from inside the script whatever the following command outputs:
ls *.aaa
and put it into a variable "listoffiles".
What I tried was:
set... (3 Replies)
I'm trying to parse COBOL code to combine variables into one string. I have two variable names that get literals moved into them and I'd like to use sed, awk, or similar to find these lines and combine the variables into the final component. These variable names are always VAR1 and VAR2. For... (8 Replies)
Hi,
When I execute this command
prtdiag -v
output sample :
System clock frequency: 160 MHZ
Memory size: 4GB
==================================== CPUs ====================================
E$ CPU CPU
CPU Freq Size ... (4 Replies)
&& echo "PLEASE enter the command to capture output" || echo "Processing your command manual"
x=$#
echo $x
while
do
while man $@ | read -r line
do
>$@.txt
... (1 Reply)
I want to search files (basically .cc files) in /xx folder and subfolders.
Those files (*.cc files) must contain #include "header.h" AND x() function.
I am writing it another way to make it clear,
I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Hi I want to check if some process is sleeping. I can see that in truss -p <pid>
I want to capture output and check that output if proces sis sleeping. Please suggest way to capture output of truss command or other way to check if process is sleeping (1 Reply)
Is there any way to trigger a sequence of commands in parallel and capture their output in variables? e.g. something on the following lines
x=`echo "X" &`
y=`echo "Y" &`
z=`echo "Z" &`
so that $x, $y, and $z evaluate to X, Y and Z res. (7 Replies)
Hi
I want to know how capture all user command line output and save this commands and outputs to text files?
if you have script for this subject please give me.:o
please help me
thank you (6 Replies)
My issue :
I am getting only last command output data in ouput file. Though comamnd "print(output)" displays data for all 3rd column values but the data saved in file is not what required it hs to be the same which is being printed by command"print(output)".
Could you please help me to fix this,... (0 Replies)
Discussion started by: as7951
0 Replies
LEARN ABOUT MOJAVE
curlopt_readfunction
CURLOPT_READFUNCTION(3) curl_easy_setopt options CURLOPT_READFUNCTION(3)NAME
CURLOPT_READFUNCTION - read callback for data uploads
SYNOPSIS
#include <curl/curl.h>
size_t read_callback(char *buffer, size_t size, size_t nitems, void *instream);
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READFUNCTION, read_callback);
DESCRIPTION
Pass a pointer to your callback function, as the prototype shows above.
This callback function gets called by libcurl as soon as it needs to read data in order to send it to the peer - like if you ask it to
upload or post data to the server. The data area pointed at by the pointer buffer should be filled up with at most size multiplied with
nmemb number of bytes by your function.
Your function must then return the actual number of bytes that it stored in that memory area. Returning 0 will signal end-of-file to the
library and cause it to stop the current transfer.
If you stop the current transfer by returning 0 "pre-maturely" (i.e before the server expected it, like when you've said you will upload N
bytes and you upload less than N bytes), you may experience that the server "hangs" waiting for the rest of the data that won't come.
The read callback may return CURL_READFUNC_ABORT to stop the current operation immediately, resulting in a CURLE_ABORTED_BY_CALLBACK error
code from the transfer.
The callback can return CURL_READFUNC_PAUSE to cause reading from this connection to pause. See curl_easy_pause(3) for further details.
Bugs: when doing TFTP uploads, you must return the exact amount of data that the callback wants, or it will be considered the final packet
by the server end and the transfer will end there.
If you set this callback pointer to NULL, or don't set it at all, the default internal read function will be used. It is doing an fread()
on the FILE * userdata set with CURLOPT_READDATA(3).
DEFAULT
The default internal read callback is fread().
PROTOCOLS
This is used for all protocols when doing uploads.
EXAMPLE
Here's an example setting a read callback for reading that to upload to an FTP site: https://curl.haxx.se/libcurl/c/ftpupload.html
AVAILABILITY
CURL_READFUNC_PAUSE return code was added in 7.18.0 and CURL_READFUNC_ABORT was added in 7.12.1.
RETURN VALUE
This will return CURLE_OK.
SEE ALSO CURLOPT_READDATA(3), CURLOPT_WRITEFUNCTION(3), CURLOPT_SEEKFUNCTION(3), CURLOPT_UPLOAD(3), CURLOPT_POST(3),
libcurl 7.54.0 February 03, 2016 CURLOPT_READFUNCTION(3)