03-03-2010
redirection stdin
Bonjour,
Mon application en C sous linux tourne en redirigeant stdin vers un fichier.
Exemple; $appli1 <file1.
[Cette appli s'arrête donc régulièrement sur un scanf();]
PB: Je voudrais temporairement redonner la main au user sur le clavier.
Alors je pensais ajouter system("appli2"); dans appli1.
Dans son main() , appli2() fait seulement un scanf(); puis un exit().
Mais lorsque appli1 reprend la main, stdin reste assigné au clavier et
non plus à file1. Or je voudrais qu'il reste assigné à file1!!!
Merci d'avance pour votre réponse...
10 More Discussions You Might Find Interesting
1. Programming
Hi
I am doing file redirection at console for use by my binary.
%console%> bin < inputfile
After reading in the entire file, I want my program to continue taking input from the console. So essentially I want to redirect stdin back to console. But I cant figure out how to do it.
I am... (4 Replies)
Discussion started by: nauman
4 Replies
2. Programming
hi,
how does a program know whether some data are available from stdin?
I would like to make a program which could read its data from stdin
and _if_there_is_nothing_at_stdin_ from a file which name is given
as an argument. If there is nothing in stdin and no filename is given as
argument,... (2 Replies)
Discussion started by: marquis
2 Replies
3. HP-UX
How can I access the standard-in device in HP-UX? I am trying to automate sftp on an HP-UX system. On solaris I can just do:
sftp -b /dev/fd/0 remotehost <<EOF
cd pub
ascii
get filename.txt
bye
EOF (2 Replies)
Discussion started by: dangral
2 Replies
4. Shell Programming and Scripting
hello all,
I need to create a password change utility for a database. I need to gather at the command line the username, password and database sid. I have the program currently doing this. What I would like to do is not have the new password appear on the screen when I do my read command.... (2 Replies)
Discussion started by: whited05
2 Replies
5. Shell Programming and Scripting
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)
Discussion started by: prkfriryce
4 Replies
6. Programming
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)
Discussion started by: vvaidyan
1 Replies
7. UNIX for Dummies Questions & Answers
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)
Discussion started by: vvaidyan
3 Replies
8. UNIX for Dummies Questions & Answers
When a process fork(), the child share the same file descriptors as his father. Thus, they share the same stdin. Quick and dirty exemple below (sorry for the ugly gets() call) :
#include <stdio.h>
#include <unistd.h>
int main()
{
char buf;
if (fork()) { /*parent */
... (1 Reply)
Discussion started by: milouz
1 Replies
9. Shell Programming and Scripting
Hi
I'm trying to do something on the bash command line that I will later put into a bash shell script.
I'm trying to take a program that reads stdin (using getline) and be able to keep it running in the background and fire "commands" to it. So what I thought I should do was to try taking... (3 Replies)
Discussion started by: niceguyeddie
3 Replies
10. UNIX for Dummies Questions & Answers
Hello,
my C application under unix runs in redirecting stdin to a file.
Example:$appli1 <file1. This application waits often on a scanf().
But I would temporarely reassign stdin at the keyboard for waiting a user's answer. So I thought to add system("appli2"); in the code of appli1. In its... (4 Replies)
Discussion started by: cypleen
4 Replies
LEARN ABOUT DEBIAN
net::bonjour::entry
Net::Bonjour::Entry(3pm) User Contributed Perl Documentation Net::Bonjour::Entry(3pm)
NAME
Net::Bonjour::Entry - Support module for mDNS service discovery (Apple's Bonjour)
SYNOPSIS
use Net::Bonjour;
my $res = Net::Bonjour->new(<service>[, <protocol>]); $res->discover;
foreach my $entry ( $res->entries ) { print $entry->name, "
"; }
DESCRIPTION
Net::Bonjour::Entry is a module used to manage entries returned by a mDNS service discovery (Apple's Bonjour). See Net::Bonjour for more
information.
METHODS
new([<fqdn>])
Creates a new Net::Bonjour::Entry object. The optional argument defines the fully qualifed domain name (FQDN) of the entry. Normal usage
of the Net::Bonjour module will not require the construction of Net::Bonjour::Entry objects, as they are automatically created during the
discovery process.
address
Returns the IP address of the entry.
all_attrs
Returns all the current attributes in the form of hashed array.
attribute(<attribute>)
Returns the specified attribute from the TXT record of the entry. TXT records are used to specify additional information, e.g. path for
http.
dnsrr([<record type>])
Returns an DNS answer packet of the entry. The output will be in the format of a Net::DNS::Packet object. The record type designates the
resource record to answer with, i.e. PTR, SRV, or TXT. The default is PTR.
fetch
Reloads the information for the entry via mDNS.
fqdn
Returns the fully qualifed domain name (FQDN) of entry. An example FQDN is server._afpovertcp._tcp.local
hostname
Returns the hostname of the server, e.g. 'server.local'.
name
Returns the name of the entry. In the case of the fqdn example, the name would be 'server'. This name may not be the hostname of the
server. For example, names for presence/tcp will be the name of the user and http/tcp will be title of the web resource.
port
Returns the TCP or UDP port of the entry.
sockaddr
Returns the binary socket address for the resource and can be used directly to bind() sockets.
EXAMPLES
Print out a list of local websites
print "<HTML><TITLE>Local Websites</TITLE>";
use Net::Bonjour;
my $res = Net::Bonjour->new('http');
$res->discover;
foreach my $entry ( $res->entries) {
printf "<A HREF='http://%s%s'>%s</A><BR>",
$entry->address, $entry->attribute('path'),
$entry->name;
}
print "</HTML>";
Find a service and connect to it
use Net::Bonjour;
my $res = Net::Bonjour->new('custom');
$res->discover;
my $entry = $res->shift_entry;
socket SOCK, PF_INET, SOCK_STREAM, scalar(getprotobyname('tcp'));
connect SOCK, $entry->sockaddr;
print SOCK "Send a message to the service";
while ($line = <SOCK>) { print $line; }
close SOCK;
SEE ALSO
Net::Bonjour
COPYRIGHT
This library is free software and can be distributed or modified under the same terms as Perl itself.
Bonjour (in this context) is a trademark of Apple Computer, Inc.
AUTHORS
The Net::Bonjour::Entry module was created by George Chlipala <george@walnutcs.com>
perl v5.10.0 2007-03-18 Net::Bonjour::Entry(3pm)