- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Writing Variables to a File
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:29 AM
12-22-2004 02:29 AM
Writing Variables to a File
I need to write several variables to a file. I'm trying...
echo "$CPU $TTY $PID $USERNAME $PRI $NI $SIZE $RES $STATE $TIME $WCPU $CPU $COMMAND" > /home/sysadmin/topcpu/check_cpu.txt
but it is not working. Can someone tell me what I'm doing wrong?
Thanks to all
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:38 AM
12-22-2004 02:38 AM
Re: Writing Variables to a File
What kind of content do you get in the file (empty)?
Is this run from a script with a different environment or other variable settings?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:40 AM
12-22-2004 02:40 AM
Re: Writing Variables to a File
You will see everything you need and then some.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:44 AM
12-22-2004 02:44 AM
Re: Writing Variables to a File
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:53 AM
12-22-2004 02:53 AM
Re: Writing Variables to a File
ls -l /home/sysadmin/topcpu
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:54 AM
12-22-2004 02:54 AM
Re: Writing Variables to a File
Do you get an error message?
Or what do you find in the file if it is created at all?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:55 AM
12-22-2004 02:55 AM
Re: Writing Variables to a File
I just tried your echo, and I get the script created (empty line because none of the VARs have values...) so I suspect you have something wrong with the permissions on your directory, has whatever executes the script the write permission to that directory?
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:55 AM
12-22-2004 02:55 AM
Re: Writing Variables to a File
# set -o|grep clobber
noclobber off
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 02:57 AM
12-22-2004 02:57 AM
Re: Writing Variables to a File
even if the file should at least be created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 03:00 AM
12-22-2004 03:00 AM
Re: Writing Variables to a File
I guess you parse the top dump from something similar to
top -d 2 -f /tmp/top.dump
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 03:20 AM
12-22-2004 03:20 AM
Re: Writing Variables to a File
- Tags:
- missing attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 03:27 AM
12-22-2004 03:27 AM
Re: Writing Variables to a File
top -d 1 -n 1 -f /home/sysadmin/topcpu/topck.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 03:41 AM
12-22-2004 03:41 AM
Re: Writing Variables to a File
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 03:56 AM
12-22-2004 03:56 AM
Re: Writing Variables to a File
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 04:13 AM
12-22-2004 04:13 AM
Re: Writing Variables to a File
Stupid question, but have you tried to run your script with the shell's poor man's debugger "sh -x"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 04:16 AM
12-22-2004 04:16 AM
Re: Writing Variables to a File
(I hope not on your screen ;-)
So at least one of us is heaving a white Xmas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 05:45 AM
12-22-2004 05:45 AM
Re: Writing Variables to a File
I've got a lot of replies to look into. I'll assign points accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 06:01 AM
12-22-2004 06:01 AM
Re: Writing Variables to a File
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 06:06 AM
12-22-2004 06:06 AM
Re: Writing Variables to a File
echo "$var1 $var2" > /newfile.txt
My problem was my last if statement wasn't evaluating the correct variable. Oversight on my part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 06:06 AM
12-22-2004 06:06 AM
Re: Writing Variables to a File
# 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 06:09 AM
12-22-2004 06:09 AM
Re: Writing Variables to a File
echo "$var1 $var2" > filename
should work fine. Maybe try it without the quotes around the variable and see what happens?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 06:14 AM
12-22-2004 06:14 AM
Re: Writing Variables to a File
Thanks to all who helped. Working from home is great, if you have the tools
Happy Holiday's to all!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2004 06:15 AM
12-22-2004 06:15 AM