Which script/shell/program launched a given script?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Which script/shell/program launched a given script?
# 1  
Old 02-24-2010
Which script/shell/program launched a given script?

Dear gurus,

I was wondering if anybody can help.

Is it possible to distinguish whether a script was launched from a shell (interactively) or was called from another script?

I basically need to do the following: if the script was run from the command line, I want to enable logging of the script into a file. If the script is called via another script, I do not wish to have any specific logging at all; instead I would like all std output and errors to be logged by the calling script's log

Any help would be greatly appreciated.
# 2  
Old 02-24-2010
Quote:
Originally Posted by Snakeye
Dear gurus,

I was wondering if anybody can help.

Is it possible to distinguish whether a script was launched from a shell (interactively) or was called from another script?
What system? What shell?

For BASH, my ~/.bashrc has this code:
Code:
if [[ $- != *i* ]]; then
        # Shell is non-interactive.  Be done now
        return
fi

# 3  
Old 02-24-2010
apologies. This is Solaris 10, korn shell

---------- Post updated at 05:16 PM ---------- Previous update was at 05:12 PM ----------

I have tried this on a test shell script that just output a line on a logfile.

I tried then executing the script by running it from the shell prompt and by running another script that calls it. In both cases, the variable returned the same thing
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute a command after a program was launched

Hi Experts, I am creating a script to monitor a certain applications running in my Unix system. My script order goes this way: df -h /of/a/filesystem tail -5 /path/to/an/application/availability su -c "jsmon pf=(profile of my application) `echo "p"`" usradm #EOF I am... (7 Replies)
Discussion started by: Xworks
7 Replies

2. Programming

Regarding Python Program with Shell Script

Hi All, I have written a shell script which is using the expect method, it is working fine in terminal window, and then I have executed via python script its also working fine in command prompt functioning properly, I used subprocess.Popen method to execute the shell script file, its working... (0 Replies)
Discussion started by: janaefx
0 Replies

3. Shell Programming and Scripting

[Solved] Process dies when launched in system startup script

Good morning! I'm trying to add Maven to the system boot by the moment without success. Testing the operation of the script I realize that the process isn't persistent when the program is launched with the start option. ---- #Startup Script ---- #! /bin/sh # chkconfig: 345 99 1 #... (5 Replies)
Discussion started by: carpannav
5 Replies

4. Shell Programming and Scripting

Killing a program in shell script

I followed the directions here Free Twitter Source Code ? Twitter Database Server: Install and created a php script that enters twitter keyword searches into a MySQL DB. When you execute the files outlined in the above link, a script starts indefinitely. I've noticed that the scripts... (6 Replies)
Discussion started by: phpchick
6 Replies

5. Shell Programming and Scripting

Deleting all the parallel processes launched when the main script receives a ctrl+c

Hi, I have a shell script that creates 2 parallel processes. When I press ctrl+c, i want the parallel process to get killed as well. #!/bin/bash cmd1="script1.py" cmd2="script2.py" ${cmd1} & pid1=$! echo ${pid1} ${cmd2} & pid2=$! (7 Replies)
Discussion started by: sana.usha
7 Replies

6. Shell Programming and Scripting

shell script program

shell script in Unix/Linux to find the lines numbers of a text file are having word which is 5 to 10 characters long and having first letter as a capital letter. (3 Replies)
Discussion started by: usersnehal
3 Replies

7. Shell Programming and Scripting

script run when executable is launched

I need to know how to have a BASH script run every time Firefox is launched, what is the simplest way to do this? (1 Reply)
Discussion started by: glev2005
1 Replies

8. Shell Programming and Scripting

program for multiplication in shell script

Hi, I wanted to write a schell program that fetches the values from a file and prints the output as its onerall multiplication. for example I have a file named abc. it has values 2, 3, 4 now my program should give me 2*3*4 ie 24. note:this file abc can have any numbers. so experts,... (9 Replies)
Discussion started by: sandeep.krish
9 Replies

9. Shell Programming and Scripting

Need help on C-shell script program

#!/bin/csh # This program will add integers # # # add integer1 .. # # Check for argument if ($#argv == 0 ) then echo "usage: add integers" exit 1 else set input = $argv endif # set sum = 0 foreach var ( $input ) @sum = $sum + $input end # (1 Reply)
Discussion started by: haze21
1 Replies

10. Filesystems, Disks and Memory

shell script program

shell script for sorting,searchingand insertion/deletion of elements in a list (1 Reply)
Discussion started by: jayaram_miryabb
1 Replies
Login or Register to Ask a Question