Problem in calling a script inside a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in calling a script inside a script
# 1  
Old 06-22-2012
Problem in calling a script inside a script

Hi team,

I have a script in different folder. Now i want to call that script and execute that script from that path alone.

My code is
HTML Code:
#!/bin/bash
wname=yahoo
PATH='/opt/IBM'
wac=`/usr/bin/ls $PATH | /usr/bin/grep "$wname"`
STOP=`/usr/bin/find $PATH/$wac -type f -name "stop.sh"`
/usr/bin/sh $STOP & (here i am executing the script in background)
/usr/bin/sleep 5 
kill  (after 5 sec it need to kill the sleep process)
# 2  
Old 06-22-2012
$! holds the PID of the last background process that was executed
This User Gave Thanks to complex.invoke For This Post:
# 3  
Old 06-22-2012
Best is to use another variable name instead of PATH.PATH is a system variable and may cause issues when using otherway.
And you need not to give "&" for background process.You may call the main script in background as well
# 4  
Old 06-22-2012
Off topic: The $PATH environment variable is reserved for the Shell. Choose another name for your environment variable ... $SEARCH ?

If you overwrite $PATH in the manner of your script, the Shell will not be able to find any command (ls / find / grep ... whatever) from that point on.
This User Gave Thanks to methyl For This Post:
# 5  
Old 06-22-2012
Not sure what's a file and what's a directory in your script and whether the string "yahoo" is the full name or part of the name of something.

What is the output from this enquiry:
Code:
file `ls /opt/IBM | grep "yahoo"`

Does the path to stop.sh ever change?
# 6  
Old 06-22-2012
Are you sure there will always only a single stop.sh be found?
# 7  
Old 06-22-2012
Quote:
Originally Posted by aashish.sharma8
Best is to use another variable name instead of PATH.PATH is a system variable and may cause issues when using otherway.
And you need not to give "&" for background process.You may call the main script in background as well

thanks aashish sharma,

I have rename PATH todifferent variable name, now its working fine.

But how to call the mail script in background ?

---------- Post updated at 08:24 AM ---------- Previous update was at 08:20 AM ----------

Quote:
Originally Posted by methyl
Not sure what's a file and what's a directory in your script and whether the string "yahoo" is the full name or part of the name of something.

What is the output from this enquiry:
Code:
file `ls /opt/IBM | grep "yahoo"`

Does the path to stop.sh ever change?

o/p of that command is
/opt/IBM/yahoo/stop.sh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling one script inside another

Hi, I am calling a script log.sh from output.sh. Log.sh has below pice of code: IFILE=/home/home1/Report1.csv if awk -F, '$6==0 && $7==0{exit 1}' ${IFILE} then awk -F, ' BEGIN{ c=split("1,6,2,3,4,5,6", col) print "To: abc@gmail.com" print "Subject: Error... (2 Replies)
Discussion started by: Vivekit82
2 Replies

2. Programming

Calling another expect script inside an expect script

I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues: set REMOTE "/root/scripts/remote" ... log_user 1 send_user "Executing remote script as $user...\n" send_user "Command to execute is: $REMOTE... (1 Reply)
Discussion started by: brettski
1 Replies

3. Shell Programming and Scripting

Calling a function in cpp file inside shell script

Hi I need to call a function written in a cpp file with arguments inside the shell script..Can anyone help me how to do this:( (1 Reply)
Discussion started by: rkrish
1 Replies

4. Shell Programming and Scripting

Problem while calling a script within a script

Hi , I have moduled my scripts in three scripts . From First script i am calling second and from second i am calling third for some check . Problem is with the third script call. ---In second script EXP ='test.\abc.\Server.*abc.xml.*' pid=$($HOME/bin/checkpid $EXP) --Third... (2 Replies)
Discussion started by: amrishn
2 Replies

5. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

6. Shell Programming and Scripting

calling problem in perl script

Hi , Here is my piece of code-- main(); sub main { $result = GetOptions ("LogDir=s" => \$LogDir, "Summary" => \$Summary, "Indiviual=s" => \$Individual , "Diagnostics=s" => \$Diagnostics, ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

7. Shell Programming and Scripting

differences in calling another script inside script

Hello, we can call the script inside another script. like method 1) content of test.sh ######## . test2.sh ####### method 2) content of test.sh ######## test2.sh ####### What is the difference here in both samples calling test2.sh?? i mean calling with ". " and calling... (1 Reply)
Discussion started by: balareddy
1 Replies

8. Shell Programming and Scripting

Problem with Calling sql file from shell script

I have created abc.sh file which will set the environment variables (UNIX env variables as well as ORACLE required variables like ORACLE_SID,ORACLE_HOME etc) and then calls a function file which checks for starts some logs and then it will try to execute the .sql file. The .sh, function file are as... (1 Reply)
Discussion started by: sskc
1 Replies

9. Shell Programming and Scripting

shell script calling problem

Hi all, I am calling one shell script from other ...as follow ---calling_proc---code line_no=10 proc_name='test' echo "set verify off feedback off pagesize 0 select count(*) from tp_mpolicy2 " | sqlplus -s/@CMKT | read cnt if ; then export $line_no $proc_name global_proc... (2 Replies)
Discussion started by: dhananjaysk
2 Replies

10. Shell Programming and Scripting

calling a C executable from inside a Perl script

here's the Perl code snippet... how can i call my C executable 'porter-stemmer' and pass it $1 as an argument? Thanks for the help! # Read through the original topic set, and modify based on the current # pre-processing options while (<TOPIC_ORIG>) { # Run pre-processing over only the... (3 Replies)
Discussion started by: mark_nsx
3 Replies
Login or Register to Ask a Question