Sponsored Content
Top Forums Shell Programming and Scripting Time out in shell script for a stament/line Post 302138497 by porter on Tuesday 2nd of October 2007 02:12:26 AM
Old 10-02-2007
You would need to

spawn a child process which captures it's pid
spawns another child process which does sleep followed by kill of that pid
set up a trap handler
spawn another child process to exec the command capturing the pid of that process
wait for the exec child to finish
clear that pid variable
in the trap handler, if the pid variable is still set then kill that pid
if the killer child has not finished, kill it

alarming?
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem with nested if stament

hi everybody: could anybody tell me what I'm doing wrong. I've tried to nest if staments like this: if condition1]; then if condition2];then if condition3];then commands else commands fi elif condition4];then commands... (3 Replies)
Discussion started by: tonet
3 Replies

2. Shell Programming and Scripting

Shell script to count number of ~ from each line and compare with next line

Hi, I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each... (3 Replies)
Discussion started by: Ganesh Khandare
3 Replies

3. Shell Programming and Scripting

get the fifth line of a text file into a shell script and trim the line to extract a WORD

FOLKS , i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one. thanks... Venu (3 Replies)
Discussion started by: venu
3 Replies

4. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

5. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

6. Shell Programming and Scripting

Shell script to read multiple options from file, line by line

Hi all I have spent half a day trying to create a shell script which reads a configuration file on a line by line basis. The idea of the file is that each will contain server information, such as IP address and various port numbers. The line could also be blank (The file is user created). Here... (1 Reply)
Discussion started by: haggismn
1 Replies

7. Shell Programming and Scripting

How to read a two files, line by line in UNIX script and how to assign shell variable to awk ..?

Input are file and file1 file contains store.bal product.bal category.bal admin.bal file1 contains flip.store.bal ::FFFF:BADC:CD28,::FFFF:558E:11C5,6,8,2,1,::FFFF:81C8:CA8B,::FFFF:BADC:CD28,1,0,0,0,::FFFF:81C8:11C5,2,1,0,0,::FFFF:81DC:3111,1,0,1,0 store.bal.... (2 Replies)
Discussion started by: veeruasu
2 Replies

8. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

9. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies
wait3(2)							System Calls Manual							  wait3(2)

NAME
wait3(), wait4() - wait for child process to change state SYNOPSIS
DESCRIPTION
The and functions allow the calling process to obtain various status information for a caller's child process based on the options speci- fied. If status information is available for two or more child processes, the order of which process to report status on is not defined. The function is similar to except that waits for a specific child as indicated by the pid parameter. Note that the following call is equivalent to the call: Note that the following call is equivalent to the call: In both of the previous prototypes, on successful completion, if the resource_usage argument to or is not a null pointer, the structure that the resource_usage argument points to is filled in for the child process identified by the return value. The pid argument specifies a child process for which status is requested. The following rules define which status information is returned: o If pid is equal to (pid_t) -1, status is requested for any child process. o If pid is greater than 0, it specifies the process ID of a single child process for which status is requested. o If pid is 0, status is requested for any child process whose process group ID is equal to that of the calling process. o If pid is less than (pid_t) -1, status is requested for any child process whose process group ID is equal to the absolute value of pid. The stat_loc argument is the address where status about the specified child process is placed. The options argument is constructed from the bitwise-inclusive OR of zero or more of the following flags defined in the header file: The status of any continued child process specified by pid that has not been reported since it continued is reported to the requesting process. The and functions will not suspend execution of the calling process if status is not immediately available for one of the child processes specified by pid. This causes the wait not to be registered. This means that the registered process that is being waited on, can be waited on again with identical results, provided that the status of the child does not change in the meantime. The status of any child processes specified by pid that are stopped and whose status has not yet been reported since they stopped, will also be reported to the requesting process. The resource_usage argument points to the resource utilization structure. APPLICATION USAGE
Threads Considerations In a multi-threaded application, only the calling thread is suspended by and The and functions will not return until all threads in the process have reached the desired state. For example, and will not return until all threads have terminated. If the or options are specified, and will not return until all threads have stopped or continued respec- tively. RETURN VALUE
If or returns because the status of a child process is available, the return value is the process ID of that child process. If or returns due to the receipt of a signal, the return value receives a and is set to If or was called with the options argument where status is not available for any process specified by the pid argument, will be returned. Otherwise, (pid_t) will be returned and will be set to indicate the error. ERRORS
If or fails, is set to one of the following values: The calling process has no existing unwaited-for child processes; or the states specified by the options argument are invalid for the set of processes specified by the pid argument. Problems were encountered in the retrieval of status information for the specified child process. The or function has been interrupted by a signal. The value in the location pointed to by the stat_loc argument is unde- fined. The options argument to or is invalid. WARNINGS
The behavior of and is affected if the signal is set to See the WARNINGS section of signal(5). Signal handlers that cause system calls to be restarted can affect the condition described above (see bsdproc(3C) and sigaction(2)). AUTHOR
The and functions were developed by HP, AT&T, and the University of California, Berkeley. SEE ALSO
exec(2), exit(2), fork(2), pause(2), wait(2), waitpid(2). wait3(2)
All times are GMT -4. The time now is 07:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy