Thread: c shell scripting!!

  1. #1
    Registered User
    Join Date
    Apr 2005

    c shell scripting!!

    does a system call return value??

    if not how would i get the menu choice to return some value
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #define script "dialog --backtitle \"Linux Shell Script Tutorial\" \
    --title \"Main Menu\" --menu \
    \"Move using [UP] [DOWN],[Enter] to Select\" 15 50 3\
    1 \"Shows Date and Time\" 2 \"To see calendar\" 3 \"To start vi editor\" "
    int main(int arg1, char *arg2[])
    int a;
    return 0;
    thanks for your time

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Quote Originally Posted by
    The system() function runs the given command as a system call. The return value is usually zero if the command executed without errors. If command is NULL, system() will test to see if there is a command interpreter available. Non-zero will be returned if there is a command interpreter available, zero if not.
    Why not just use mostly C?
    #include <stdio.h>
    #include <stdlib.h>
    int main(int arg1, char *arg2[])
    	int a;
    	printf("Linux Shell Script Tutorial\n");
    	printf("Main Menu:\n");
    	printf(" [1] Show Date and Time\n [2] See Calendar\n [3] Start Vi\n");
    	printf("Please Choose a number: ");
    	else if(a==2)
    	return 0;
    also, avoid using system() - it opens your program up to security breaches.
    Join is in our Unofficial Cprog IRC channel
    Channel: #Tech

    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Still in the egg
    >also, avoid using system() - it opens your program up to security breaches

    Sure...You should use fork()-execv() for exexcutin a command within your program.

    You may want to see your system's manual page for system() call.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shell Scripting...redirecting executable output?
    By Kleid-0 in forum A Brief History of
    Replies: 2
    Last Post: 05-13-2005, 10:50 AM
  2. What shell is more powerful?
    By xddxogm3 in forum Tech Board
    Replies: 10
    Last Post: 07-24-2004, 10:47 PM
  3. Directories + shell scripting
    By MethodMan in forum Linux Programming
    Replies: 2
    Last Post: 03-28-2002, 12:07 AM
  4. shell scripting ????
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 02-14-2002, 04:31 PM