Find the answer to your Linux question:
Results 1 to 3 of 3
I must create shell program in c. Change dir and Cls command for cleare screen. I dont need use existing commands, i need programming shell code. Plese Help me. Sorry ...
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Posts
    1

    How change dir using c program !!!

    I must create shell program in c.

    Change dir and Cls command for cleare screen.
    I dont need use existing commands, i need programming shell code.


    Plese Help me. Sorry my eanglish is bad. Greets from Bosnia. MILICA

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    i hope this is not homework

    Code:
    man system
    man chdir
    read these man pages

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    In a C program, the system("cd newdir") will not work since the system/shell command called is context-sensitive. IE, the directory set is only valid for that temporary shell used to execute the command. You need to use the chdir() system call, which will change the working directory for your application. That's what shells like bash et al use.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...