Click to See Complete Forum and Search --> : running a script in the background..
SpookyFox
01-20-2001, 12:32 AM
Gooooood evening!
I'm here because I was curious. I'm trying to figure out how to right a script that executes multiple times, and that allows me to get to my bash prompt again. How does one do this? I've tried various for loops, but all of them just run in the foreground. How do I make it just continuously run in the background?
Thanks!
Spooky
wmHardRock
01-20-2001, 01:03 AM
Add a & at the end of the command?
SpookyFox
01-20-2001, 03:30 AM
okay, the script I'm writing is for this wargame computer at www.hackerslab.org. (http://www.hackerslab.org.)
I know it's cheesy, I know it's lame, but I'm trying to figure it out. (It's a legal 'hacking' playground computer)
I'm currently at level 8, and I know what I'm needing to do. The code I wrote to execute the 'ps2' command on the computer is as follows:
#include "stdio.h"
int main(void) {
for(i=0;;i++) {
system("/usr/bin/ps2 &");
}
return 0;
}
Okay, if you compile that, it'll execute the command endlessly like I want, but it will not bring me back to a bash prompt. Any thoughts? I'm just not sure what I have to do to let me run it AND have the prompt to work at...
Spooky
SpookyFox
01-20-2001, 03:32 AM
Nevermind, I just figured it out. Don't mind me!
Thanks for the help!
Spooky
Frymaster
01-20-2001, 03:33 AM
the ampersand in the system() call bg's that call, but for the calling program to return to the prompt you need to run it with an ampersand as well...
SpookyFox
01-20-2001, 02:58 PM
That makes perfect sense. I wish I could thought of it! http://www.linuxnewbie.org/ubb/smile.gif
Thanks again for the help!
Spooky