LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2011, 02:26 PM   #16
z1p
Member
 
Registered: Jan 2011
Location: the right coast of the US
Distribution: Ubuntu 10.04
Posts: 80

Rep: Reputation: 23

A couple of things.

#1 backtick the du command
#2 Use parens in the if statement
#3 add an 'endif' for the if statement
#4 fix the logic of the if statement. it is backwards.
I chose to switch which variable was used for what as the names made more sense to me that way.

#5 the script needs some work to make it more robust.
such as: check if the file exists, have a delay between checks, possible some exit condition, ...


Code:
#!/bin/csh
echo Enter a file name
set file aFILE = $<                                          ##Name of file
echo enter a size in kilobytes to monitor
set SIZETOMON = $<                                     ##Size value that's input by user
set SIZE = `du -k $aFILE | sed s/$aFILE//g`            ##Size of the file  that the user wishes to monitor
while (1)
if ($SIZE > $SIZETOMON) then
echo ALERT: File size is greater than $SIZETOMON
endif
end

Last edited by z1p; 03-10-2011 at 02:44 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/csh.cshrc: Permission denied........................ saqibsh Linux - Software 11 03-29-2010 05:04 AM
csh: permission denied jjguo Linux - Newbie 14 09-17-2008 11:29 PM
Root gets permission denied on rw local filesystem sfc Linux - Software 0 02-17-2006 11:17 AM
Permission Denied for script accessing text file lobo1 Linux - General 2 06-28-2005 12:46 PM
Accessing Win2K Shares-permission denied bdog Linux - Networking 4 01-26-2002 07:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration