What is wrong with this code?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What is wrong with this code?
# 1  
Old 06-23-2003
Question What is wrong with this code?

Hello everyone, can somebody tell me what is wrong with this code:
Code:
while true
do
	java myTime > myTime.log
	sleep 60
done

I get the following error:

./myTime: Syntax error at line 1 : `while' is not matched.

Thanks in advance!
# 2  
Old 06-23-2003
Re: What is wrong with this code?

Quote:
Originally posted by Lem2003
Hello everyone, can somebody tell me what is wrong with this code:
Code:
while true
do
	java myTime > myTime.log
	sleep 60
done

I get the following error:

Try using : (NULL operator) instead of true. What shell are you in?
# 3  
Old 06-23-2003
Is it complaining about the script you posted or the script it is running via java?

The code you posted works and gives no error on Solaris 8 (the 'java' line was not tested).

I tried the code in both sh and ksh (you should post what you are coding in and the OS/version).
# 4  
Old 06-23-2003
Thanks guys!
I'm working on HP-UX Release 11i: November 2000 in sh. I also tried:
Code:
while :
do
	java myTime > myTime.log
	sleep 60
done

And it does not work. I get the same error. Thanks once again.
# 5  
Old 06-23-2003
I found the problem! I was using a scprit made in notepad. I used vi and found a bunch of funny chars. Thanks everybody.
# 6  
Old 06-23-2003
DOS/Windows text files have a Carriage Return and Line Feed at the end of the file, whereas Unix files have only a Line Feed (no carriage return). ^M is the carriage return...

See this webpage for more info: UNIX vs DOS/WINDOWS File Formats
# 7  
Old 06-23-2003
MySQL

Yeah ^M was what I found in the script!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is wrong with my awk code?

Hi there, I am trying to select a number of lines based on the lat. lon columns in a file but my awk code gives me empty result. Here is my file: 20100213 102212 33.1185 39.4078 2.9 20100214 141753 33.1058 39.9068 2.9 20100218 115828 33.1907 39.3575 2.9 20100225 220001 33.1932 39.9448... (10 Replies)
Discussion started by: johankor
10 Replies

2. Shell Programming and Scripting

What's wrong with my bash code?

I want to let sleep 3 in the background and echo $i pkglists="a b c d e f g" f() { local i set -- $pkglists && ((i +=2)) && sleep 3 &;echo $i } f (3 Replies)
Discussion started by: yanglei_fage
3 Replies

3. Shell Programming and Scripting

What is wrong with my code?

Hello, all Suppose my current directory has 3 files: file_1 file_2 file_3 I wrote the following codes: awk 'BEGIN{while("ls"|getline d) {myarray++}}; END{close("ls");for (i in myarray){print i, myarray}}' /dev/null I expect the output be like: 1 file_1 2 file_2 3 file_3 ... (7 Replies)
Discussion started by: littlewenwen
7 Replies

4. Shell Programming and Scripting

Whats wrong With This Code

Hi , iam new with sed command D:\bfx_db>sed -ne '/^SP2-*:/S/^\<.*\.*\>$/\2\p' reg.sql >>D:\out.log The filename, directory name, or volume label syntax is incorrect. Here my source file is reg.sql , i need the output in out.log Can anybody Help on this???? (4 Replies)
Discussion started by: mhdmehraj
4 Replies

5. Shell Programming and Scripting

What's wrong with this code?

Trying to do a file count on files between a specific date. I entered the following command, but it's not working: find . -type f \( -newer startdate -a ! -newer enddate \) -exec "ls -l | wc -l" {} \; lil help? :D (4 Replies)
Discussion started by: bbbngowc
4 Replies

6. Shell Programming and Scripting

whats wrong in my code

Code: #!/usr/bin/perl -w use strict; use warnings; #Clears Screen $CLEAR=`clear`; print $CLEAR; i get the below error: Global symbol "$CLEAR" requires explicit package name at ./mutmg.pl line 6. Global symbol "$CLEAR" requires explicit package name at ./mutmg.pl line 7. (1 Reply)
Discussion started by: sophos
1 Replies

7. Shell Programming and Scripting

What is wrong with this code

I just wanted to assign the filename to a variable filename="abc" datestrng=`date +%Y%m%d` filextn="txt" "LOCAL_FILE"${i}=${filename}"_"${datestrng}"."${filextn} echo "LOCAL_FILE"${i} I get the following error on 2nd last line ksh: LOCAL_FILE1=abc_20081114.txt: not... (3 Replies)
Discussion started by: mqasim
3 Replies

8. Shell Programming and Scripting

whats wrong with this code

ls -ld | grep $1 /etc/passwd | cut -d: -f6 i need see the content... (4 Replies)
Discussion started by: nadman123
4 Replies

9. Shell Programming and Scripting

What's wrong with this code?

Hello all, Can someone tell me why I'm getting an error in the following code: export return_code="$?" if then echo "load_shaw.sas failed." exit else echo "Trigger the next script..." # /path/to/next/script fi I get an error... (3 Replies)
Discussion started by: mmignot
3 Replies

10. Shell Programming and Scripting

Can someone review my code tell me where I am going wrong?

Started writing my code. my read input is not even asking nor working? And I get a EOF script error. echo "1) aragorn.domain.net" echo "2) marvel.domain.net" echo "3) athena.domain.net" echo "4) gandalf.domain.net" echo "5) griffin.domain.net" echo "What server would you like... (4 Replies)
Discussion started by: chrchcol
4 Replies
Login or Register to Ask a Question