Sponsored Content
Top Forums Shell Programming and Scripting Question about Shell Programming Post 18221 by LivinFree on Tuesday 26th of March 2002 03:22:10 AM
Old 03-26-2002
Cleaning up, in many cases that I've seen in shell scripting, means removing any temp files, unsetting any variables that may make it into a shell session (doesn't happen all that often - most scripts are run as a child process, as opposed to "sourced", or run as a string of commands in the current process), and handling signals properly (if the job runs as a daemon, does it ignore the SIGHUP signal correctly? What does the script do when it hits an error, or something it doesn't know how to deal with?).
Any other things to watch out for, anyone?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Post Shell programming: Question about source a file and read data from the file

This is shell programming assignment. It needs to create a file called .std_dbrc contains STD_DBROOT=${HOME}/class/2031/Assgn3/STD_DB (which includes all my simple database files) and I am gonna use this .std_dbrc in my script file (read the data from the database files) like this: .... (3 Replies)
Discussion started by: ccwq
3 Replies

2. Shell Programming and Scripting

question about about Shell programming

1.if 2.then 3. # save the number of args and first argument in variables. 4. num_args=$# 5. id="$1" 6. echo "$id" 7. #echo "$1" > crapfile.txt 8. echo `sed 's/\*/'\*'/g' < crapfile.txt` Above is a partial code.I would like to ask: at line 1:... (1 Reply)
Discussion started by: thungmail
1 Replies

3. Shell Programming and Scripting

question about testing in shell programming

I created a file named q2.c in /home/tuan/Desktop/Shell_programming. I coded a script named "test" to check whether the file existed or not. My code : #!/bin/sh submitDir=/home/tuan/Desktop/Shell_programming/submit if then echo "There is no q2.c" else echo "There is q2.c" fi After... (3 Replies)
Discussion started by: thungmail
3 Replies

4. Shell Programming and Scripting

question about testing in shell programming

Hi i would like to write a "script" which takes a directory as an argument and the script will output the content of a file in this directory.Here is my code #!/bin/sh #set an argument to be a specified path $1=/home/tuan/Desktop/Shell_programming/directory #check if an argument is a... (3 Replies)
Discussion started by: thungmail
3 Replies

5. Shell Programming and Scripting

question about testing in shell programming

I have 2 different directories. The first has 2 sub-folders A and B. The second as 2 sub-folders C and D and script named "script".There is a code of "script" to list 2 sub-folders C and D #!/bin/sh for file in * do && echo $file done I would like to ask how can I make a change if I... (2 Replies)
Discussion started by: thungmail
2 Replies

6. Shell Programming and Scripting

question about testing in shell programming(modifications were made)

In folder A i have a file "a' and text file named infile00.I would like to do redirection :a<infile01. There is a code to do this #get a file "a" in /home/A for file in /home/A/* do if $file ] then #printing out if file is an execute file echo $file "is an... (2 Replies)
Discussion started by: thungmail
2 Replies

7. Shell Programming and Scripting

question about testing in shell programming

In folder A i have a file "a' and text file named infile00.I would like to do redirection :a<infile01. There is a code to do this #get a file "a" in /home/A for file in `ls /home/A` do if then #printing out if file is an execute file echo $file "is an execute... (6 Replies)
Discussion started by: thungmail
6 Replies

8. Shell Programming and Scripting

Beginner Shell Programming Question

Hello all, I am currently try to learn the linux operating system as well as some bash programming. I have come across some online course work which has been very helpful, I have been working through some assignments and since I have no teacher to ask I have come to you experts. So the... (6 Replies)
Discussion started by: g2axiom
6 Replies

9. Shell Programming and Scripting

Plz Help Me in This question in Shell Programming

2- Write a bash shell script filestatic. The script should examine the number files in directories given as arguments (parameters) to this script. a. if one argument is given, the script should count and report the number of files in this directory. Only regular files should be counted, not... (1 Reply)
Discussion started by: tahseen_22334
1 Replies

10. Homework & Coursework Questions

Plz Help Me in This question in Shell Programming

2- Write a bash shell script filestatic. The script should examine the number files in directories given as arguments (parameters) to this script. a. if one argument is given, the script should count and report the number of files in this directory. Only regular files should be counted, not... (1 Reply)
Discussion started by: tahseen_22334
1 Replies
system(3S)																system(3S)

NAME
system() - issue a shell command SYNOPSIS
DESCRIPTION
executes the command specified by the string pointed to by command. The environment of the executed command is as if a child process were created using (see fork(2)), and the child process invoked the sh-posix(1) utility via a call to (see exec(2)) as follows: ignores the and signals, and blocks the signal, while waiting for the command to terminate. If this might cause the application to miss a signal that would have killed it, the application should examine the return value from and take whatever action is appropriate to the application if the command terminated due to receipt of a signal. does not affect the termination status of any child of the calling processes other than the process or processes it itself creates. does not return until the child process has terminated. APPLICATION USAGE
If the return value of is not -1, its value can be decoded through the use of the macros described in For convenience, these macros are also provided in Note that, while must ignore and and block while waiting for the child to terminate, the handling of signals in the executed command is as specified by fork(2) and exec(2). For example, if is being caught or is set to when is called, the child is started with handling set to Ignoring and in the parent process prevents coordination problems (such as two processes reading from the same terminal) when the executed command ignores or catches one of the signals. RETURN VALUE
If command is null, returns non-zero. If command is not null, returns the termination status of the command language interpreter in the format specified by wait(2). The termi- nation status of the command language interpreter is as specified for sh-posix(1), except that if some error prevents the command language interpreter from executing after the child process is created, the return value from is as if the command language interpreter had termi- nated using If a child process cannot be created, or if the termination status for the command language interpreter cannot be obtained, returns -1 and sets to indicate the error. DIAGNOSTICS
forks to create a child process which, in turn, in order to execute string. If the fork fails, returns -1 and sets If the exec fails, returns the status value returned by (see wait(2)) for a process that terminates with a call of ERRORS
If errors are encountered, sets values as described by fork(2). FILES
SEE ALSO
sh(1), fork(2), exec(2), wait(2), thread_safety(5). STANDARDS CONFORMANCE
system(3S)
All times are GMT -4. The time now is 12:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy