I’ve got strange issue with simple shell script that I want to ouptut result to textfile which I will use later for reading some content.
shell script
#!/bin/sh
for file in $(find -name .curlrc ); do
grep -q “curl -k” $file
if [ $? -eq 0 ]; then
echo “‘curl -k’ |found in file| "$file"”
else
echo “‘curl -k’ |not found in file| "$file"”
fi
done
command to run from bigfix
wait chmod +x “/var/tmp/findcurlrc”
wait /bin/sh “/var/tmp/findcurlrc” >> “/var/tmp/findcurlrc.txt”
Checking the client logs not seeing any errors
Command started - wait chmod +x “/var/tmp/findcurlrc” (action:3685886)
Command succeeded (Exit Code=0) wait chmod +x “/var/tmp/findcurlrc” (action:3685886)
At 15:24:06 +0000 - actionsite (http://bfixroot.pg.com:29450/cgi-bin/bfgather.exe/actionsite)
Command started - wait /bin/sh “/var/tmp/findcurlrc” >> “/var/tmp/findcurlrc.txt” (action:3685886)
Command succeeded (Exit Code=0) wait /bin/sh “/var/tmp/findcurlrc” >> “/var/tmp/findcurlrc.txt” (action:3685886)
At 15:24:06 +0000 -
ActionLogMessage: (action:3685886) ending action
Issue I’m facing is that the textfile /var/tmp/findcurlrc.txt is not getting created.
when i run the script from the server directly it works just fine and text file is created.
I’ve also tried below approach but same result
#!/bin/sh
for file in $(find -name .curlrc ); do
grep -q “curl -k” $file
if [ $? -eq 0 ]; then
echo “‘curl -k’ |found in file| "$file"” >> “/var/tmp/findcurlrc.txt”
else
echo “‘curl -k’ |not found in file| "$file"” >> “/var/tmp/findcurlrc.txt”
fi
done
Any help/suggestions are welcome
Thx!