Does my script make any sence?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Does my script make any sence?
# 1  
Old 12-16-2011
Does my script make any sence?

What I plan on doing is have have this script run via a cron job every minute and what its going to do is look at the size of foo.txt and if it has any data then execute start_presentation_mine.sh then exit.


Code:
#!/bin/bash

ppts1=/ticker/powerpointshare
VAR=` wc -c /tmp/foo.txt | awk -F" " '{print $1}' ` 


cd $ppts1

ls -rt | tail -1 > /tmp/foo.txt


if [ "$VAR" > "0" ]; then
                wineserver -k
                sleep 5
                bash /scripts/start_presentation_mine.sh
fi

rm -f /tmp/foo.txt
exit

A issue that im starting to see is this scrip is running every minute via cron like it is supposed to but it seems to always create a blank file named 0

Last edited by binary-ninja; 12-16-2011 at 05:21 PM..
# 2  
Old 12-16-2011
Use if [ $var -gt 0 ] instead of if [ "$var" > 0 ]
">" is understood as a redirection operator in single square brackets [ ]. If you really insist on using ">" to mean greater than, use [[ ]] as in if [[ $var > 0 ]]

And, awk's default field seperator is space. So, you need not mention -F" ". var=`wc -c /tmp/foo.txt | awk '{print $1}'` would suffice.

Another alternative would be to use var=`cat /tmp/foo/txt | wc -c`
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

advise some script to make the changes..!!

Hi Folks, got the solution..!! (5 Replies)
Discussion started by: tuntun
5 Replies

2. Shell Programming and Scripting

Need help with a script to make makefile

How do we create a shell script that creates a makefile? what if we want to use the #include header files too? (2 Replies)
Discussion started by: sslokhan
2 Replies

3. UNIX for Dummies Questions & Answers

how to make script automated

if i have a script called test.sh file1=$(ls -l|awk '{print $9 $1}') awk ' /date_of_selling:/ { print $6 ":" &9 }' /$file1 >> data.txt if i wanna this script to run automatically every day at 8 am :D (3 Replies)
Discussion started by: teefa
3 Replies

4. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

5. Shell Programming and Scripting

please help me: how to make Ln in script shell

please can u help me in my homework, i want to creat a script shell for ln (symbolik link). This script will do everything that Ln do it. (1 Reply)
Discussion started by: halo03
1 Replies

6. Shell Programming and Scripting

Help to make the script simple

Hi All, I have a script which throws the output if condition matches. I run the cmd : # ldf Filesystem kbytes used avail capacity Mounted on /dev/dsk/c1t0d0s0 1984564 1375019 550009 72% / /dev/dsk/c1t0d0s3 5040814 2628410 2361996 53% /usr... (4 Replies)
Discussion started by: naw_deepak
4 Replies

7. Shell Programming and Scripting

How can I make a script to ftp over?

Hi, I have a script that ftp over the file: CFGFILE=/export/home/myuser/scripts/ftp1.cfg LOGFILE=/app/bea/logs/ LOCALPATH=/expport/home/myuser/ECNLogs/ YEAR=`date '+%Y'` MONTH=`date '+%m'` DAY=`date '+%d'` HOUR=`date '+%H'` MINUTE=`date '+%M'` LASTHOUR=$((HOUR-1)) echo $LASTHOUR ... (4 Replies)
Discussion started by: mehrdad68
4 Replies

8. Shell Programming and Scripting

make directory script

Hi, I try to write a script to create a new directory. #!/bin/bash echo "Please enter folder name (6 characters only) :" read foldername mkdir /home/user/$foldername $foldername >> /home/list/list.txt My question/situation: 1) how to ensure the folder name MUST BE 6 characters... (0 Replies)
Discussion started by: malaysoul
0 Replies

9. Shell Programming and Scripting

Help make script much easier

Is there any method to realise this in one command? Thanks in advance (2 Replies)
Discussion started by: GCTEII
2 Replies

10. Programming

make script

I need to write a make script to install a C module in a UNIX environment.It should install the sources, build the libraries and install them and also install the info pages on the system. Can this script be general enough to also install on windows, windows dll, windows help file's etc. Any... (3 Replies)
Discussion started by: cherio
3 Replies
Login or Register to Ask a Question