Hi, glad it works out so well. Perhaps you could try the same thing with the server too, see how that pans out:
I tried out your next script too and it works like a charm! I used to spend hours trying to keep track of what was going on with programs. I often had so many terminals up and running it was just plain ridiculous. Also, the processes would never die and it used to mess up the experiments I was trying to run. Truly, thank you very much for all your precious help, Scrutinizer.
My next job will be to go through your scripts and try to comment them out in detail. I will be back with questions, I'm sure. So, stand by. :-)
Gratefully,
DTW
P.S: Also if you PM me your name, I can put it in as the primary author for these scripts. I really don't want to take the credit for work that I've not done.
---------- Post updated at 04:28 PM ---------- Previous update was at 03:53 PM ----------
Let's consider this script, first:
OK, so, I'm trying to get an idea of the high-level flow here. According to me this is what is executed first:
This essentially fires up the programs by taking them in as command line arguments and starting them each off as a background process. After it has done this, it waits. Then if Ctrl+C is executed, this piece of the code is executed:
I think the "INT" stands for interrupts (which is caused by the user hitting Ctrl+C). Then, the routine "killsubs()" is called. This first outputs the line "Ctrl -C was pressed". Then it gets all the PIDs of the jobs. I'm not sure what -p does. On the man pages, we have:
Quote:
-p Display only the process IDs for the process group leaders of the selected jobs.
What does that mean? "xargs" looks like it gets all the items from the standard input and then executes the command "kill" on them. Then, we inform the user that the jobs were killed and exit cleanly. Is that a fair first pass?
Thanks,
DTW
---------- Post updated at 05:45 PM ---------- Previous update was at 04:28 PM ----------
I have a quick question:
Is there any way we could nicely print out the names of the jobs we killed? I tried putting in:
But this printed only the PIDs.
Thanks,
DTW
Last edited by DTriniWay; 01-21-2010 at 05:05 PM..
Thanks for your suggestion.
I tried the following piece of code and changed i from 0 right up to 13 but I didn't see the names of my programs anywhere. :-( Is there anything else I can try?
Thanks,
DTW
---------- Post updated at 05:17 PM ---------- Previous update was at 02:41 PM ----------
So, I finally managed to get the names working. I'll post more, later. :-)
OK, so I'm back. Apparently, adding this line to the script did the trick:
I had a buddy help me write that out. I have no idea what it exactly does in detail, though. :-)
So, the full script is now:
Thanks to all who contributed in making this script work for me. I'm grateful for your help.
I want to run a C program from my BASH script. Here's some very basic simplified code of my bash script:
#!/bin/bash
echo "Run C program"
./main.c
echo "Ran C program"
Here's my main.c:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv)
{
... (3 Replies)
I have a program which I can run on the command line like below and works fine
/nethome/chrisd/HSeis/TommyCD/TommyCD-1101/bin/raytrac vmod=npt10-z30.vmod srfile=jcdint.sc rcfile=jcdint.rc phases="SP FS" level=twop format="X T" dtau=0.1 mdacc=0.5 mindist=0.1 maxitertp=25 ray=npt10-z30.ry... (0 Replies)
Lets get some stuff out of the way before the question. I am currently running FreeBSD 7.0 on a VirtualBox virtual machine. I do not know much about Unix or FreeBSD, though I do run linux at home. My boss gave me some files that he says are a unix version of the program Dynflow. The Programs... (0 Replies)
hi ,
i need to run a parallel program .
for example;
program1
{
array=" the second program should called here : program 2"
the execution should continue
}
the 2nd program should recieve an array of information as argument and it should... (4 Replies)
Hi there! I tried to search for something like this here but couldn't find anything. I need to run a specific program when linux starts up. I need to run it after the rp-pppoe has started because this prog needs internet connection.
I start the program by entering ./dynix start (its in my home... (4 Replies)
Hi.Iam new to Linux.i got linux 7.0 pro and dont know how to run programs. I want a perl interputer and i know i installed one but how do i run it ??? Also how do i run a C or C++ editor ?and how do i run cron ? (3 Replies)
This is not a question, but rather a simple how-to for
programmers who are new to the UNIX environment.
I too,am new to UNIX.
First I developed a few programs on my box and perfected them
until they were satisfactory for execution.
Problem was however, that once i compiled and all that,... (2 Replies)
How can I make a program run automatically at a certain time of day?
My problem is I need to make a small backup program that will back up a few files every day? (3 Replies)
Just getting into the Unix command line programming and am unable to run any program I write. I am using a Makefile and the source is compiling but when I enter the name of the output file I get back:
bash: lab01exe.out: command not found
I'm sure I am just dooing something simple... (2 Replies)