03-03-2010
stdin redirection
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 main(), appli2 executes only scanf(), then exit(). But when appli2 exits then appli1 continues, stdin is still assigned to the keyboard instead of file1. But I would like that stdin stays assigned to file1.
Thank you for your answer.
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
Bonjour,
Mon application en C sous linux tourne en redirigeant stdin vers un fichier.
Exemple; $appli1 <file1.
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... (1 Reply)
Discussion started by: cypleen
1 Replies
NWAUTH(1) nwauth NWAUTH(1)
NAME
nwauth - Verify username/password
SYNOPSIS
nwauth [ -h ] [ -S server ] [ -U user name ] [ -P password | -n ] [ -D ]
DESCRIPTION
nwauth does nothing but logging into a NetWare server. If the login was successful, an error code of 0 is returned. If the login was not
successful, an error code of 1 is returned. It was designed for use by other programs who want authenticate users via a NetWare server.
If there is no -P or -n option specified on command line, nwauth always expects a password on stdin. If the stdin is a tty, then the user
is prompted for a password. Otherwise nwauth simply reads stdin for a password.
nwauth looks up the file $HOME/.nwclient to find a file server and a user name if they are not specified on command line. See nwclient(5)
for more information. Please note that the access permissions of .nwclient MUST be 600, for security reasons.
OPTIONS
-h
-h is used to print a short help text.
-S server
server is the name of the server you want to use.
-U user name
If the user name your NetWare administrator gave to you differs from your unix user-id, you should use -U to tell the server about your
NetWare user name.
-D
nwauth says that your password is correct if you have existing connection to server with name user name. This is handy for some shell
scripts, but it is unacceptable for authorization modules, such as PAM, PHP or Apache. It was pointed to me that this behavior was not
well known, and there exist at least one PAM module which does not know that (this module is not part of ncpfs; you should use PAM mod-
ule which comes with ncpfs instead anyway).
SEE ALSO
nwclient(5)
CREDITS
nwauth was written by Volker Lendecke (lendecke@math.uni-goettingen.de)
nwauth 10/27/1996 NWAUTH(1)