Calling script from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling script from script
# 1  
Old 05-20-2013
Calling script from script

I have a script that run several commands and displays them as they run. I want to call the script from another script and have the output write to a text file. I currently have a line in my calling script like;
Code:
/location_of_script/script_to_be_called > /tmp/file_to_write.txt

Nothing is getting written to the file. I don't want to have to add a > /tmp/file_to_write.txt to the end of every line in the called script but there could be 20 to 30 lines.

Last edited by Scott; 05-20-2013 at 10:46 AM.. Reason: Code tags
# 2  
Old 05-20-2013
Is the second script printing to STDIN or STDERR?
# 3  
Old 05-20-2013
the 2nd script post to STDOUT, it will display on the screen if run from command line by itself.
# 4  
Old 05-20-2013
Then you're going to have to show us the 2nd script for us to help figure out what is going on. Some programs exit if their output is not connected to a terminal device; some write directly to a hardware frame buffer. Without seeing the script, we are only guessing and you've already eliminated the most common cases for what you've said is happening.
# 5  
Old 05-21-2013
This started when we moved the server to new hardware. On the old hardware the output information is written to a text file.
Here is a portion of the script which starts one of the instances on the server.

Code:
echo "Starting Node Agents"
cd /usr/WebSphere/AppServer/profiles/AppSrv01/bin
./startServer.sh nodeagent
cd /usr/WebSphere/AppServer/profiles/AppSrv02/bin
./startServer.sh nodeagent

Code:
echo "Starting Application Servers - JVM1"
cd /usr/WebSphere/AppServer/profiles/AppSrv01/bin
./startServer.sh server1
./startServer.sh IBMDB2eServer


Last edited by zaxxon; 05-21-2013 at 11:05 AM..
# 6  
Old 05-23-2013
Quote:
Originally Posted by daveisme
the 2nd script post to STDOUT, it will display on the screen if run from command line by itself.
STDERR is also your screen, what happens if you call it this way:
Code:
/location_of_script/script_to_be_called 2>&1 > /tmp/file_to_write.txt

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

calling a shell script present on another server using perl script.

Hi, I am working on a sever A. I want to write a perl script to execute a shell script persent on the server B. please help me in this. thanks in advance. (3 Replies)
Discussion started by: anandgodse
3 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

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

8. Shell Programming and Scripting

Calling a shell script from a perl script

Hi, I have one shel script which returns some value and I am calling this shell script from a perl script which needs the out put/return value of shell script. But I don't know how to collect the output/return value of the shell script. Can any one give some idea on it? For example: The... (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

9. Shell Programming and Scripting

How to return the value from the called shell script to the calling sh script

Hi all, I have two ksh scripts #sample1.sh #!/bin/ksh . ./sample2.sh echo $fileExist #sample2.sh #!/bin/ksh func() { i=1 return $a } func echo $? Here how should I return the value of sample2.sh back to sample1.sh? Thanks in advance. (2 Replies)
Discussion started by: gp_singh
2 Replies

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