Sorry, why are you creating a socket connection? Why don't you use pipe the output of the command back to the user?
Quote:
For Linux I've tried to mimic the shell using popen(), and to write and read in the handler returned by popen(), but I cannot run /bash shell commands as cd, cp, mkdir and so on because they are internal bin/bash commands
Hunh? If you use popen, the only limitation is that you cannot both read from and write into the file descriptor. Only if that limitation is a problem do you need sockets. But you say you can't run them because they are "internal commands". But there almost always external versions of these commands available. (For cd, however, it's useless -- you must do this within the context of your program, or prefix all subsequent commands with a "cd".) Regardless, all one needs to do in this case is run bash and provide it the command to parse.
My supervisor keep getting "stdin not tty" or something like that when he pipe or redirect input into a program. Others
don't seem to get this message. Is there some way I can help him to fix or turn this off?
Thx in advance (1 Reply)
can you redirect STDIN with command arguments?
I have tried this approach:
# ./script -option <argument1> <argument2> 0<$2
# $2: ambiguous redirect
Is this possible? (4 Replies)
Hi,
Program A: uses pipe()
I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:
* child
-> dup2(fd, STDOUT_FILENO);
-> execl("/path/PROGRAM B", "PROGRAM B", NULL);
* parent
-> char line;
-> read(fd, line, 100);
Question:
---------... (1 Reply)
Hi,
Program A: uses pipe()
I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:
* child
-> dup2(fd, STDOUT_FILENO);
-> execl("/path/PROGRAM B", "PROGRAM B", NULL);
* parent
-> char line;
-> read(fd, line, 100);
Question:
---------... (3 Replies)
Hi:
I have the next script on ksh
#!/usr/bin/ksh
cd $FUENTES
qdesign <<-!
\$/opt/cognos/ph843e/bin/qtp <<-!
\$/opt/cognos/ph843e/bin/quiz <<-!
!
!
!
This script is very simple, i want to nest three process quiz into qtp, and this into qdesign.
When I run it , i receive the... (5 Replies)
Hi:
I have the next script on ksh
#!/usr/bin/ksh
cd $FUENTES
qdesign <<-!
\$/opt/cognos/ph843e/bin/qtp <<-!
\$/opt/cognos/ph843e/bin/quiz <<-!
!
!
!
This script is very simple, i want to nest three process quiz into qtp, and this into qdesign.
When I run it , i receive the next... (2 Replies)
I am unable to use STDIn redirection with < (commands)
When I do the following, both approaches work and give the same results:
1.
$ printf "aaa\nbbb\n" > file1
$ printf "111\n222\n" > file2
$ cat file1 file2
aaa
bbb
111
2222.
$ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
aaa... (8 Replies)
Hi,
i know how to
a) redirect stdout and stderr to one file,
b) and write to two files concurrently with same output using tee command
Now, i want to do both the above together.
I have a script and it should write both stdout and stderr in one file and also write the same content to... (8 Replies)
Looking for the proper way to bring a string into the stdin. I have a string that I would like to grep and awk. Each have to be run separately, not piped together. So far, the only way I could figure out how is to echo the string and pipe it:
echo 'This is my string' | grep my (3 Replies)
Hi there,
I need to execute a command in the bash. The program prints some standard (output and) error and then wants the user to choose one of several options and type the according input. I am trying to solve this issue in a bash script but also running into some circular dependency. How can I... (7 Replies)
Discussion started by: fredestet
7 Replies
LEARN ABOUT NETBSD
sockstat
SOCKSTAT(1) BSD General Commands Manual SOCKSTAT(1)NAME
sockstat -- list open sockets
SYNOPSIS
sockstat [-46clnu] [-f address_family] [-p ports]
DESCRIPTION
The sockstat command lists open Internet or UNIX domain sockets.
The following options are available:
-4 Show AF_INET (IPv4) sockets.
-6 Show AF_INET6 (IPv6) sockets.
-c Show connected sockets.
-f address_family
Limit listed sockets to those of the specified address_family. The following address families are recognized: inet, for AF_INET;
inet6, for AF_INET6; and local or unix, for AF_LOCAL.
-l Show listening sockets.
-n Numeric output only. No attempt will be made to look up symbolic names for addresses and ports.
-p ports Only show Internet sockets if either the local or foreign port number is on the specified list. The ports argument is a comma-
separated list of port numbers and ranges specified as first and last port separated by a dash.
-u Show AF_LOCAL (UNIX) sockets.
If neither -4, -6, nor -u are specified, sockstat will list sockets in all three domains.
If neither -c nor -l are specified, sockstat will list both listening and connected sockets, as well as those sockets that are in neither
state.
The information listed for each socket is:
USER The user who owns the socket.
COMMAND The command which holds the socket.
PID The process ID of the command which holds the socket.
FD The file descriptor number of the socket.
PROTO The transport protocol associated with the socket for Internet sockets, or the type of socket (stream, seqpacket or data-
gram) for UNIX sockets.
LOCAL ADDRESS For Internet sockets, this is the address to which the local end of the socket is bound (see getsockname(2)). For bound
UNIX sockets, it is the socket's filename or ``-''.
FOREIGN ADDRESS The address to which the foreign end of the socket is bound (see getpeername(2)) or ``-'' for unconnected UNIX sockets.
SEE ALSO fstat(1), netstat(1), inet(4), inet6(4), unix(4)HISTORY
The sockstat command appeared in FreeBSD 3.1. It was then rewritten for NetBSD 3.0.
AUTHORS
This version of the sockstat command was written by Andrew Brown <atatat@NetBSD.org>. This manual page was written by Dag-Erling Smorgrav
<des@FreeBSD.org> and was adapted to match the NetBSD implementation by Andrew Brown <atatat@NetBSD.org>.
BSD July 14, 2006 BSD