Strange fork error while running script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strange fork error while running script
# 1  
Old 06-03-2016
Hammer & Screwdriver Strange fork error while running script

Code:
more run.sh

!/bin/bash
input="data.txt"
while IFS= read -r var
do
startdir="/web/logs"
searchterm=$(echo $var | awk -F'=' '{print $1}')
replaceterm=$(echo $var | awk -F'=' '{print $2}')

find "$startdir" -type f -exec grep -l "$searchterm" {} + |
while read file
do if sed -e "s#$searchterm#$replaceterm#g" "$file" > /tmp/tempfile.tmp
then mv /tmp/tempfile.tmp "$file"
printf "Modified: %s\n" "$file"
fi
done
rm -f /tmp/tempfile.tmp
done < "$input"
echo "*** Yay! All Done! ***"

When data.txt has the below entry the run.sh works fine
Code:
more data.txt

yellow=hello

But, when I change the data.txt entry as below run.sh fails
Code:
more data.txt

10.112.34.5=102.3.12.43

run.sh fails with the below fork error.
Code:
bash-3.2$ ./run.sh.sh
./replacestring.sh: line 1: !/bin/bash: No such file or directory
./replacestring.sh: fork: Not enough space
 *** Yay! All Done! ***

Code:
uname -a
SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v

Why i m getting fork error when i change entries in data.txt?
What is the fix ?

Any help will be appreciated.

Last edited by mohtashims; 06-03-2016 at 11:17 AM..
# 2  
Old 06-03-2016
Replace this...

Code:
 !/bin/bash

with this...

Code:
 #!/bin/bash

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

SUDO error in Solaris: auth.error] fork

I cannot solve the following error bellow. Can someone help me on this please? Mar 31 07:08:45 serverx sudo: fork Mar 31 07:18:50 serverx sudo: fork Mar 31 07:28:45 serverx sudo: fork Mar 31 07:38:47 serverx sudo: fork Mar 31 07:48:45 serverx sudo: fork Mar 31 07:58:45 serverx... (1 Reply)
Discussion started by: pangarano
1 Replies

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

3. AIX

Strange problem running python program from within ant

Hello, I'm currently trying to port an ant based build to AIX 6.1. The build queries the underlying version control system (Mercurial) for some data, which works fine on other platforms (Linux, Solaris). However, on AIX the hg command fails to load python's md5 module when used in the build,... (1 Reply)
Discussion started by: dhs
1 Replies

4. Programming

Why am i getting these strange packets while running my packet capture module written in c.?

I have made an packet capture application running on intel machine, it is capturing packets with src address- 17.0.0.0 destination ip- 66.0.0.0, source port- 0, destination port- 0, and protocol- 0 what does these packets mean ? The code written to interpreter captured bytes is given below.... (5 Replies)
Discussion started by: arunpushkar
5 Replies

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

6. Shell Programming and Scripting

Strange error in bash script

Howdy all, I have a scritp that does a sqldump. But for some goofy reason, a certain part of it behaves uber strange. It does a daily dump of my sql, according to parameters I enter in hardcode. The script is: #!/bin/bash APP_NAME="app_com_site" wikiname="wiki_com_site" ... (8 Replies)
Discussion started by: saariko
8 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 Advanced & Expert Users

Error occured while running a script

Hi All, In my application, I'm getting an error as type mismatch Let me now explain the scenario, I ran a shell script which calls some other scripts. All these scripts uses the environment variables. Take for example, this script uses a variable 'PathDir'. I initiallized the value to... (2 Replies)
Discussion started by: iamgeethuj
2 Replies

9. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: aama100
2 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