Results 1 to 5 of 5
Hi,
I've one main script, which at runtime calls two scripts, in which the 1st script uses the 2nd script as argument for its execution in the main script.
I ...
- 04-16-2009 #1Just Joined!
- Join Date
- Jun 2006
- Posts
- 40
Not getting script's output in the log file ?
Hi,
I've one main script, which at runtime calls two scripts, in which the 1st script uses the 2nd script as argument for its execution in the main script.
I may not be explaning clearly. So, here's the case:
All my three scripts (main, 1st, 2nd) lies under the same path "/home/pawan/".
Main script:
-------------------------------------
logsfile="/home/pawan/logging"
script_path="/home/pawan"
echo "inside main script..." 1>>${logsfile} 2>>${logsfile}
${script_path}/test11 ${script_path}/test12 2>>$script_path/errr
echo "exiting main script" 1>>${logsfile} 2>>${logsfile}
-------------------------------------
1st script:
-------------------------------------
echo "inside 1st script...." 1>>${logsfile} 2>>${logsfile}
echo "$1" 1>>${logsfile} 2>>${logsfile}
echo "exiting 1st script..." 1>>${logsfile} 2>>${logsfile}
-------------------------------------
2nd script:
-------------------------------------
echo "inside 2nd script...." 1>>${logsfile} 2>>${logsfile}
echo "Did you get how the flow is going" 1>>${logsfile} 2>>${logsfile}
echo "exiting 1st script..." 1>>${logsfile} 2>>${logsfile}
-------------------------------------
Now, Iam getting only the output from the main script into my "logging" file as I redirected the standard output & the standard error into my logging file.
But, I am not getting the output from the test11 & test12 scripts into my "logging" file, where I've used the redirection in the same way I did for the main script.
Any help.....in this matter....will be highly appreciated.
Thanks in advance...!!!
Regards,
Pawan
- 04-16-2009 #2Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Ok,
The variables you define in your first script must be exported so that they are available to the other scritps. You also omitted the shell that should be used interpret the script.
Changes in bold text.
Script test11 doesn't call test12 at all:Code:#!/bin/bash export logsfile="/home/pawan/logging" export script_path="/home/pawan" echo "inside main script..." 1>>${logsfile} 2>>${logsfile} ${script_path}/test11 ${script_path}/test12 2>>$script_path/errr echo "exiting main script" 1>>${logsfile} 2>>${logsfile}
Script test12 logs exiting 1st sctipt, not 2nd.Code:#!/bin/bash echo "inside 1st script...." 1>>${logsfile} 2>>${logsfile} echo $1 1>>${logsfile} 2>>${logsfile} ${1} 2>>${logsfile} echo "exiting 1st script..." 1>>${logsfile} 2>>${logsfile}
Result:Code:#!/bin/bash echo "inside 2nd script...." 1>>${logsfile} 2>>${logsfile} echo "Did you get how the flow is going" 1>>${logsfile} 2>>${logsfile} echo "exiting 2nd script..." 1>>${logsfile} 2>>${logsfile}
Code:inside main script... inside 1st script.... <path>test12 inside 2nd script.... Did you get how the flow is going exiting 2nd script... exiting 1st script... exiting main script
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 04-16-2009 #3Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Hmmm, did I just do somebody's homework?
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 04-16-2009 #4Just Joined!
- Join Date
- Jun 2006
- Posts
- 40
Thanks a lot for your quick response.
Yes, infact you corrected some of my mistakes, but those echo lines are just used for example.
I've got the point from your effective comments. I'll try to work in this same way in my scripts.
Its not really a homework, I am troubleshooting some scripts. hence, was trying to understand the meaning where two scripts were called on the same line in the main script.
Thanks & Regards,
Pawan
- 04-16-2009 #5Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539

You're welcomeRHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.


Reply With Quote