Operating System - HP-UX
1751847 Members
5096 Online
108782 Solutions
New Discussion юеВ

Re: Writing Variables to a File

 
Scott Frye_1
Super Advisor

Re: Writing Variables to a File

Here is my entire script.
Georg Tresselt
Honored Contributor

Re: Writing Variables to a File

Is there a ">" missing in this line?

top -d 1 -n 1 -f /home/sysadmin/topcpu/topck.txt
http://www.tresselt.eu
Stephen Keane
Honored Contributor

Re: Writing Variables to a File

It's not the old shell can't deal with floating point numbers in comparisons malarky again is it?
Patrick Wallek
Honored Contributor

Re: Writing Variables to a File

OK, I think I may have found part of your issue.

In your script you read in a command into the variable COMM.

However you use the variable COMMAND rather than COMM in several places, including an IF statement. Fix that and you might see a bit of progress.
Ralph Grothe
Honored Contributor

Re: Writing Variables to a File

Does any of your if tests, in whose body you write to check_cpu.txt, ever evaluate to true?

Stupid question, but have you tried to run your script with the shell's poor man's debugger "sh -x"?
Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Writing Variables to a File

Off topic, where do you get the heavy snow?
(I hope not on your screen ;-)
So at least one of us is heaving a white Xmas.
Madness, thy name is system administration
Scott Frye_1
Super Advisor

Re: Writing Variables to a File

Snow is in Indianapolis IN.

I've got a lot of replies to look into. I'll assign points accordingly.
Scott Frye_1
Super Advisor

Re: Writing Variables to a File

OK, to follow up with a few things...
Yes /home/sysadmin/topcpu exists

Permissions are set as root, running script as root.

Changed COMMAND to COMM, still doesn't create files.

And yes, some of my if statements do evalutate to true.

Seems like this should be so easy, I don't know why I can't get these files to create. I'm sure I've missed something.
Scott Frye_1
Super Advisor

Re: Writing Variables to a File

Well, I knew it was something I was doing (at least part of it). I got the files to create but they are empty. I can figure the rest of it out I think. Just to make sure, is there any reason I shouldn't expect to see data in my files by doing
echo "$var1 $var2" > /newfile.txt

My problem was my last if statement wasn't evaluating the correct variable. Oversight on my part.
Patrick Wallek
Honored Contributor

Re: Writing Variables to a File

OK, how about doing this for us and posting the results:

# sh -x scriptname

Or just put

#!/usr/bin/sh -x

at the top of the script, execute it and attach the results. Maybe the trace will give us some more clues.