LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-19-2004, 10:52 AM   #1
stefanero
LQ Newbie
 
Registered: Apr 2004
Posts: 2

Rep: Reputation: 0
how to send a pw to a programm?!


hello

I am new to programming and I just want to write a little programm which sends a password to another programm

I don't really care if perl or C

but let me explain a little better...

First I want to start in the script A, Programm B. Then Programm B will wait for a Passwort to be inserted.
At that point I would want the script A to contiue and send the pw. so that the programm B contious loading

any clues how to do that?!

thnx very much
stefanero
 
Old 04-19-2004, 11:43 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
man popen.
 
Old 04-19-2004, 12:09 PM   #3
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
A sample from Wrox Linux Programming (Chapter 11):
Code:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main()
{
    FILE *read_fp;
    char buffer[BUFSIZ + 1];
    int chars_read;

    memset(buffer, '\0', sizeof(buffer));
    read_fp = popen("uname -a", "r");
    if (read_fp != NULL) {
        chars_read = fread(buffer, sizeof(char), BUFSIZ, read_fp);
        if (chars_read > 0) {
            printf("Output was:-\n%s\n", buffer);
        }
        pclose(read_fp);
        exit(EXIT_SUCCESS);        
    }
    exit(EXIT_FAILURE);
}
and another one:
Code:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int main()
{
    FILE *write_fp;
    char buffer[BUFSIZ + 1];

    sprintf(buffer, "Once apon a time, there was...\n");
    write_fp = popen("od -c", "w");
    if (write_fp != NULL) {
        fwrite(buffer, sizeof(char), strlen(buffer), write_fp);
        fclose(write_fp);
        exit(EXIT_SUCCESS);        
    }
    exit(EXIT_FAILURE);
}
 
Old 04-19-2004, 02:25 PM   #4
stefanero
LQ Newbie
 
Registered: Apr 2004
Posts: 2

Original Poster
Rep: Reputation: 0
hey

thnx very much

stefanero
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
daemon exec X-programm dakien Programming 2 06-08-2005 07:57 AM
Programm like DriveImage? morto Linux - Software 2 02-01-2005 09:18 AM
What Chess Programm Should I Use?? Electronkz Linux - Software 2 04-15-2004 09:22 PM
installing a programm on linux Fresha Linux - Software 5 02-19-2004 10:36 AM
Programm to capture films saavik Linux - Software 3 03-22-2003 04:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration