simple shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simple shell
# 1  
Old 08-27-2009
Network simple shell

Hi everyone

I am writing a simple shell but the background '&' not working i dont understand

this is my fork

pid_t pid;
pid=fork();


if(pid<0)
{
printf("\nChild process failed.");
exit(1);
}
else if(pid==0)
{
if(execvp(argv[0],argv)<0)
{

printf("command not found.\n");
exit(1);
}
}



else if(background==1)
{
pid = waitpid(pid, NULL, 1);
if (pid > 0)
printf("working %d\n", pid);

}


and this is my seaching key '&' code

printf("");
gets(inputBuffer);

strcpy(history[j++],inputBuffer);
parse(inputBuffer,argv);
if (strcmp(argv[0], "exit") == 0)
exit(0);

zzz=strchr(inputBuffer,'&');
if(zzz!=NULL){

background=1;

}
else {
background=0;

}


who help me ?
# 2  
Old 08-27-2009
i guess your script was not so simple after all Smilie can you post the stdout and stderr
# 3  
Old 08-27-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.
  1. Use Code Tags when you post any code or data samples so others can easily read your code.
    You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
  2. Avoid adding color or different fonts and font size to your posts.
    Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
  3. Be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply With Quote
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on simple shell script

Hello, I need to create one very simple shell script that checks if the first character of the file ./pump.txt is 0 and in that case gives a message. If the first character is instead 1, it does give a different message. I have written: irr= head -c 1 ./pump.txt if ]; then echo... (4 Replies)
Discussion started by: dcaccount
4 Replies

2. Shell Programming and Scripting

Simple Shell Script? Someone help?

Write a shell script which adds up 10 numbers entered by the user and displays the result to the screen. You must use the read command to obtain the numbers from the user. Im a nooby noob (2 Replies)
Discussion started by: LinuxNubBrah
2 Replies

3. Shell Programming and Scripting

Help with simple Shell Script

Hi , I am in need of simple shell script that has one input file containing some words Input file 1 : ****ALEX***JOHN*******VIRGIL***** CHRITINE*****FAISAL*****DON***** ****ALEX***JOHN*******VIRGIL***** CHRITINE*****FAISAL*****DON***** ****ALEX***JOHN*******VIRGIL*****... (6 Replies)
Discussion started by: kmanjuna
6 Replies

4. Shell Programming and Scripting

Help :: Simple Shell Scripting

Hello, I want to find the "IP-OF-SERVER" in /etc/squid/squid.conf And replace it with The IP of server. I know this command returns the IP of server : ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' And I can replace with sed. : sed -i... (4 Replies)
Discussion started by: Ghadamyari
4 Replies

5. Shell Programming and Scripting

Simple Shell Script

Hello Friends, I am writing a shell script which will grab a file if it exists and copies it to another folder and will append with current date. I have written but gives me error, plz help: -------------------------------------------- #!/usr/bin/sh source=/home/dev4rice/naveen/test1... (4 Replies)
Discussion started by: ganesh123
4 Replies

6. Shell Programming and Scripting

simple shell - how to get a parameter typed in a shell script

Hi, I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
Discussion started by: cmitulescu
4 Replies

7. UNIX for Advanced & Expert Users

I need of a simple shell script

Hi, I need of a simple shell script to launch a perl script. The complet path of the script is: /export/home/x2693/project/v02/appliancemanagement.pl (2 Replies)
Discussion started by: Minguccio75
2 Replies

8. Shell Programming and Scripting

need a simple shell script

Hi, I am new to unix as well as shell programming. Any body can provide me a simple shell script which should copy/transfer/fetch a file(using FTP)from remote server to local system.and it should log the details when it was fetched.If there is any error,the error msg should log in log... (1 Reply)
Discussion started by: Mar1006
1 Replies

9. Shell Programming and Scripting

simple shell scripts

hi everyone... i'm new to this shell programming and i want help with the following question... i hope someone can help me ...pls plsssssssssss ========================================================== the question ========================================================== A number of... (1 Reply)
Discussion started by: moon14
1 Replies

10. Shell Programming and Scripting

A simple shell question

Hi all... here is my question: in the following, will the `cd $ref_ntp` work? for i in `cat $fic` do { echo " " echo ================$i============================= OS=`$CMD -s $i "uname"` case $OS in SunOS) ref_ntp=/ref/ntp/SUN ;; HP-UX) ref_ntp=/ref/ntp/HP ;; esac ... (2 Replies)
Discussion started by: a_new_admin
2 Replies
Login or Register to Ask a Question