Problem while calling a script within a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem while calling a script within a script
# 1  
Old 07-12-2011
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
Code:
EXP ='test.\abc.\Server.*abc.xml.*'
 
pid=$($HOME/bin/checkpid $EXP)
 
--Third Script --checkpid
pattern=$1
pid=$(pgrep -f $pattern -u $USER)
if [[ -n "$pid" ]]; then
  echo $pid
else
  exit 1
fi

Now when i am directly calling the checkpid script with the expression it is giving me proper result but when i am calling it from the second script ,it is showing me error
Code:
pgrep: option requires an argument -- u
Usage: pgrep [-flvx] [-d DELIM] [-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]
        [-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]

I have tried putting echo in third script but i am unable to see it in the log file.

Please help me with the same.

Last edited by pludi; 07-12-2011 at 09:19 AM..
# 2  
Old 07-12-2011
Have you verified that the value of $USER is not empty?
# 3  
Old 07-12-2011
ok..will try to check..but i m unable to get output of echo in the third script..thru console value of USER is showing proper but i m calling first script from another application.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

2. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

3. Shell Programming and Scripting

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 #!/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"`... (8 Replies)
Discussion started by: natraj005
8 Replies

4. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

5. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This application's startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

6. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

7. 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

8. Shell Programming and Scripting

passing a variables value from the called script to calling script using ksh

How do i get the value of the variable from the called script(script2) to the calling script(script1) in ksh ? I've given portion of the script here to explain the problem. Portion of Script 1 ============= ----- ----- tmp=`a.ksh p1 p2 p3` if then # error processing fi -----... (10 Replies)
Discussion started by: rajarkumar
10 Replies

9. 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

10. 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
Login or Register to Ask a Question