Sponsored Content
Top Forums Programming How to Run a Linux Command and Redirect its output to a socket in C Post 302255952 by rajeshomallur on Friday 7th of November 2008 12:03:01 PM
Old 11-07-2008
How to Run a Linux Command and Redirect its output to a socket in C

I have a Linux socket server program. I need to run the commands sent by the client and return the output to client. Is there a quicker way?

I tried with
ptr=popen(command, "r"); and then
fgets(buf, size,ptr);
write buf to socket

fgets hangs for me.

Now, I would like to know if I can re-direct the output of popen() or system() to the client socket. How can I do that?

Thank you very much.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

redirect command output to variable

Hi, I am looking for a way to redirect the result from a command into a variable. This is the scenario. Using the find command I will be getting multiple records/lines back. Here is the command I am using: find /”path”/ -name nohup.out -print This now is giving me the paths and file... (1 Reply)
Discussion started by: hugow
1 Replies

2. Shell Programming and Scripting

redirect output of dos2unix command

hi I want to suppress the output of dos2unix command in my shell script. I'm using follwing command in my script dos2unix somefile >/dev/null But it's still showing output while executing the script.Please help me to sort this out Thanks (4 Replies)
Discussion started by: nrbhole
4 Replies

3. Filesystems, Disks and Memory

in Oracle Enterprise Linux not able to redirect pvscan output

hi, In Oracle Enterprise Linux I'm not able to redirect output of commands pvscan and vgscan into a file. File is coming blank Please suggest something Thanx. (1 Reply)
Discussion started by: discover
1 Replies

4. Linux

In Oracle Enterprise Linux, not able redirect pvscan output

Hi, I'm not able to redirect output of ovscan and vgscan commands to a file in Oracle Enterprise Linux. Please suggest something. Thanks Mayank (1 Reply)
Discussion started by: discover
1 Replies

5. UNIX and Linux Applications

How to redirect grep command output to same file

Hi Everyone, Can anyone please tell me, how can I redirect the grep command output to same file. I am trying with below command but my original file contains no data after executing the command. $grep pattern file1 > file1 Kind Regards, Eswar (5 Replies)
Discussion started by: picheswa
5 Replies

6. Shell Programming and Scripting

Receiving 'ambiguous redirect' when trying to run command against multiple files

I came across the command string on https://www.unix.com/shell-programming-scripting/141885-awk-removing-data-before-after-pattern.html which was what I was looking for to be able to remove data before a certain pattern. However, outputting the result to a file seems to work on an individual basis... (4 Replies)
Discussion started by: HLee1981
4 Replies

7. Solaris

Script redirect command output failed, why?

Hi, I put a for loop in a script to eject backup tapes from the robot. The command echo' output goes to the log file without problem, but command vmchange's output does not go to the log file although it's working fine. It still displays on the screen. I've tried '2>&1 1>$log', but nothing changed.... (5 Replies)
Discussion started by: aixlover
5 Replies

8. AIX

Not able to redirect output of command

Hi All,. We are using AIX as the OS to host the Oracle ERP. We have a command FNDLOAD which is used to load setups. When this command is run, it outputs names of log files and any errors to the screen. I am trying to redirect this output to a file because we have large number of these... (4 Replies)
Discussion started by: mansmaan
4 Replies

9. Shell Programming and Scripting

Redirect output of command line to for loop

I would like to redirect output of command line in for loop as $line. Output should be processed as line but instead it throw whole output. Could somebody help me on how to redirect output of command line and process it line by line without sending output to any file. below is my code ... (1 Reply)
Discussion started by: tapia
1 Replies

10. Shell Programming and Scripting

How to redirect the output of a command inside ftp block?

hi, i am using ftp to get files from remote server. inside the ftp i want to us ls -ltr command and send the output of it to a file. ftp -n remote_server <<_FTP quote USER username quote PASS password prompt noprompt pwd ls -ltr get s1.txt bye _FTP i... (4 Replies)
Discussion started by: Little
4 Replies
UUIDD(8)						       System Administration							  UUIDD(8)

NAME
uuidd - UUID generation daemon SYNOPSIS
uuidd [options] DESCRIPTION
The uuidd daemon is used by the UUID library to generate universally unique identifiers (UUIDs), especially time-based UUIDs, in a secure and guaranteed-unique fashion, even in the face of large numbers of threads running on different CPUs trying to grab UUIDs. OPTIONS
-d, --debug Run uuidd in debugging mode. This prevents uuidd from running as a daemon. -F, --no-fork Do not daemonize using a double-fork. -k, --kill If currently a uuidd daemon is running, kill it. -n, --uuids number When issuing a test request to a running uuidd, request a bulk response of number UUIDs. -P, --no-pid Do not create a pid file. -p, --pid path Specify the pathname where the pid file should be written. By default, the pid file is written to /run/uuidd/uuidd.pid. -q, --quiet Suppress some failure messages. -r, --random Test uuidd by trying to connect to a running uuidd daemon and request it to return a random-based UUID. -S, --socket-activation Do not create a socket but instead expect it to be provided by the calling process. This implies --no-fork and --no-pid. This option is intended to be used only with systemd(1). It needs to be enabled with a configure option. -s, --socket path Make uuidd use this pathname for the unix-domain socket. By default, the pathname used is /run/uuidd/request. This option is pri- marily for debugging purposes, since the pathname is hard-coded in the libuuid library. -T, --timeout number Make uuidd exit after number seconds of inactivity. -t, --time Test uuidd by trying to connect to a running uuidd daemon and request it to return a time-based UUID. -V, --version Output version information and exit. -h, --help Display help screen and exit. EXAMPLE
Start up a daemon, print 42 random keys, and then stop the daemon: uuidd -p /tmp/uuidd.pid -s /tmp/uuidd.socket uuidd -d -r -n 42 -s /tmp/uuidd.socket uuidd -d -k -s /tmp/uuidd.socket AUTHOR
The uuidd daemon was written by Theodore Ts'o <tytso@mit.edu>. SEE ALSO
uuid(3), uuidgen(1) AVAILABILITY
The uuidd daemon is part of the util-linux package and is available from the Linux Kernel Archive <https://www.kernel.org/pub/linux/utils /util-linux/>. util-linux July 2014 UUIDD(8)
All times are GMT -4. The time now is 06:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy