error in in running script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting error in in running script
# 1  
Old 10-19-2008
error in in running script

Hi all,

I have created a script file .sh and had some allias commands, local variable, some grep features, and listing files/directories, and it worked correctly and I got the outputs I am looking for after I run the script . However, some of the grep commands and some other functions did not worked after I tried to run the script in another script to get the output of the original script printed in another scrip so I can print out the output. Does anyone know what is the problem with that ?


e.g. my is script kk.sh and it runs and prints the output after I run it the permission is 700
.
.
Then I did:
script output.out <enter>
kk.sh
exit
.
.
some of the outputs didn't worked in output.out.. why? and how I can fix it ?

Last edited by aama100; 10-19-2008 at 09:42 PM..
# 2  
Old 10-19-2008
Hammer & Screwdriver Without seeing what you wrote, this is difficult to understand

However,
script1.sh
does some stuff
exits and you can see desired results

script2.sh
does some stuff
calls script1.sh
(script1 is now a child process)
gets unexpected results

script2 can export variables for use by the child script1; but the reverse is not true. Variables set in the called script1 are not known by script2.

for instance, with the following code
Code:
script2.sh
   x=12
   export $x
   script1
   echo $x $y
exit
script1.sh
   y=13
   export $y
   echo $x $y
exit

running script2.sh will show
12 13
12

The top line is from script1.sh since it knows both variables
The second line is from script2.sh and it only knows x
# 3  
Old 10-20-2008
Does your kk.ksh have a shebang line at the beginning, e.g. #!/usr/bin/ksh? The reason I ask is because when you run script, by default it launches a standard sh shell, so unless you have a shebang line in your script it may be running under sh insted of the usual ksh, and could explain why some of your code no longer works.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error running script

Hi, I have the the below script more runcda.sh if *\).*/\1/p' $1_dr) ]; then echo "ParallelGCThreads Found with Value" else echo "ParallelGCThreads Not Found - Add !!" fi $ ./runcda.sh output.log ./runcda.sh: test: argument expected ParallelGCThreads Not Found - Add !! Why am i... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Error in running DB query by script

Hi I was trying to fetch data from database. But the number of rows exported were huge so i got the error. Experts please advice. Thanks a lot for your supprt. #: ./script.sh ./script.sh: xmalloc: subst.c:3076: cannot allocate 1401346369 bytes (0 bytes allocated) (2 Replies)
Discussion started by: brij123
2 Replies

3. Shell Programming and Scripting

Error when running script in background

Hi guys, ./test.sh & #!/usr/bin/ksh echo "No.Of Items :" read count echo "Report Time (Min):" read time some other command .... exit 0; thanks (3 Replies)
Discussion started by: asavaliya
3 Replies

4. Shell Programming and Scripting

Error while running script using nohup

Hi, I am running the below script. When i run the script normally it executes fine but when i run the same script using nohup it throws an error as getStatus.sh: syntax error at line 3: `(' unexpected . Can you let me know why it is so? while do . $(dirname $0)/include.sh cd... (2 Replies)
Discussion started by: vignesh53
2 Replies

5. UNIX and Linux Applications

Getting error code when running the script 2 (RC)2

hi All, we have a script to remove the files from particular path,when we tryingto run manually the script went to success and removed the files but the same script which is running by other team it got failed and giving the error "2 (RC)2 "..what is the cause of the failure..and we passing the... (2 Replies)
Discussion started by: nagavenkatesh
2 Replies

6. Shell Programming and Scripting

Error running nawk script

Hi, I was trying to use nawk script given in this link https://www.unix.com/aix/19979-df-output-not-aligned.html but when i do this im getting this error $ df -k|formatDF.nawk -ksh: formatDF.nawk: not found Can anyone help me on this... (6 Replies)
Discussion started by: niteesh_!7
6 Replies

7. Solaris

Error when running script

Hi All, Need your guuys help here. #!/bin/bash { echo "POLICY LIST" echo "====================================" bppllist echo " " echo "POLICY DETAILS" echo "====================================" for type in daily weekly monthly quarterly echo... (6 Replies)
Discussion started by: ronny_nch
6 Replies

8. UNIX for Dummies Questions & Answers

Getting error when running script through crontab

Hi all, I wrote small script for Solaris and when I am running it through command prompt its ok, but when I trying to run it using crontab, i am getting error like: ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory /tmp/file.sh: line 5: 8304 Killed ... (4 Replies)
Discussion started by: nypreH
4 Replies

9. Shell Programming and Scripting

Error while running your script -- Balamv

When I run this, I am getting the below error. Why? Pls help me #!/bin/ksh echo Hello World dirs="not_using_0" for entry in *; do && dirs="$dirs $entry" done dirarray=($dirs) index=1 while }" ] ; do echo "${index}: ${dirarray}" index=`expr $index + 1` done while ; do echo -n... (1 Reply)
Discussion started by: balamv
1 Replies

10. UNIX for Dummies Questions & Answers

Error while running a script

Hi all, By running a (command) script I'm getting the following error: .: /usr/bin/test: cannot execute binary file This is the command: $ . test The script (test) is very simple sqlplus user/password @1.sql sqlplus user/password @2.sql Can enyone tell me what the problem is. (5 Replies)
Discussion started by: HarryTellegen
5 Replies
Login or Register to Ask a Question