Thread: Shell script

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    16

    Shell script

    Please see the attached

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Since the OP was to lazy to actually write it out:
    Ok here is my C program below. I want to write a shell script that will interact with the program below and print out just the input from the user to the screen.

    Program:

    Code:
    #include <stdio.h>
    
    main()
    {
    float a , b;
    printf("Input two numbers... \n");
    scanf("%f%f" , &a , &b);
    printf("%f , a , b );
    }
    How do I create a shell script to print out only the inputs?

  3. #3
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    search google takes like two seconds. I don't know what shell you are in I'll assume bash
    Code:
    #!/bin/sh
    echo Input two numbers:  
    read num1
    read num2
    echo "The two numbers are $num1 and $num2"
    here is a simple site bash programming

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    16
    I am using the C Shell

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Consider this a warning to go use something else
    http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    16
    I have to use it for my assignment.

    I just want to write a shell script that outputs the numbers that the user inputs. The above program is called nprog.c and it prints to an output file called nprog

    I have writtten a shell script the is called the_script. Within the_script I have:

    #!/bin/csh -f

    nprog


    From this I can type the_script and the program will run. The problem is I don't want the entire program to print. I just want to be able to get the numbers that was inputed and stored into nprog to be printed out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. shell script basic question
    By PedroTuga in forum Linux Programming
    Replies: 1
    Last Post: 09-09-2006, 03:24 AM
  2. invoking shell script
    By agoel01 in forum C Programming
    Replies: 1
    Last Post: 12-01-2005, 11:37 AM
  3. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM
  4. Running 'exec' twice in one UNIX shell script
    By Zughiaq in forum Tech Board
    Replies: 2
    Last Post: 05-03-2003, 12:04 AM
  5. Arguements with a shell script
    By Doh in forum Linux Programming
    Replies: 1
    Last Post: 11-28-2002, 02:20 PM