Shell script check syntax not working ...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script check syntax not working ...
# 1  
Old 07-18-2013
Shell script check syntax not working ...

Hello i have question that i want check syntax from my script shell with sh -n filename
but it's not show something even i have wrong syntax in my file. why can this happened or any other way to check it?

i use on header of file :

#!/bin/sh

thx before Smilie
# 2  
Old 07-18-2013
# 3  
Old 07-18-2013
I have been use that clue .. but it doesn't happened even my script is wrong ...

---------- Post updated at 11:59 AM ---------- Previous update was at 11:57 AM ----------

I have been use that clue .. but it doesn't happened even my script is wrong ...

like :
sh -n /path/to/scriptfile
Or put set -n at the top of your script.
# 4  
Old 07-18-2013
-n (parse only) does not find all syntax errors.
-x is a real run with echoing after evaluation.
# 5  
Old 07-18-2013
What shell are you using?

What OS are you using?

What is in filename and /path/to/scriptfile?

What is it in those files that you are expecting to produce a syntax error?
# 6  
Old 07-18-2013
1 sh or bash shell

2 linux centos.

3 in that file is scripting, like day_N=`date +%d-%m-%Y`

4 not produce, but i want with this checking can show the error syntax before execute / run that script
ex: day_N=`dateas +%d-%m-%Y` -> that will show error command dateas not found. like that

for detail question : i want to know the error syntax without run that script....

thx
# 7  
Old 07-18-2013
Quote:
Originally Posted by Gochengz
1 sh or bash shell

2 linux centos.

3 in that file is scripting, like day_N=`date +%d-%m-%Y`

4 not produce, but i want with this checking can show the error syntax before execute / run that script
ex: day_N=`dateas +%d-%m-%Y` -> that will show error command dateas not found. like that

for detail question : i want to know the error syntax without run that script....

thx
Not finding a command is not a syntax error. Without running the script the shell can't know whether a utility named dateas will be the name of an alias, function, built-in, or utility found through $PATH at the time when the script will get to that point.

Syntax errors are things like a missing fi or then in an if statement or a missing do or done in a while loop.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with if statement syntax in shell script

I want to make the file test condition a variable ($Prmshn in code below). My goal is to use something like the first three unsuccessful if statetments since the 'if #!/bin/ksh test_input() { Prmshn=${1} InFLNm=${2} ifReq="-$Prmshn $InFLNm" #the following three if statments fail: #if ] ;... (10 Replies)
Discussion started by: ms63707
10 Replies

2. Shell Programming and Scripting

Help with Check Syntax of Shell Script without Running

Hi Everyone, Is there any way ( generic) to check syntax of Shell Scripts without running it?? (4 Replies)
Discussion started by: roy121
4 Replies

3. Shell Programming and Scripting

CHECK SCRIPT SYNTAX

Hi everyone, i'd like someone chechk this script, i know it's very simple but it doesn't work good, let me tell you this script works over huge directories, maybe that's the problem, if somebody can give me other way to develop, or show me where it's the problem, i'll appreciate it. ... (9 Replies)
Discussion started by: Newer
9 Replies

4. Shell Programming and Scripting

syntax error in shell script

I am creating a shell script. In which, I need to get server name and server IP. I used this command in script. servername=`cat /etc/hosts|grep `eval hostname`|awk '{print $2}'` however, when execute script or put set -x to debug, it return: line 13: syntax error at line 13: `|' unexpected... (4 Replies)
Discussion started by: duke0001
4 Replies

5. Shell Programming and Scripting

shell script | bc syntax format

sorry but need help http://i.investopedia.com/inv/articles/site/CalculationEMA.gif trying to achieve ema in script I have this syntax which errors ema=` ; the 0.153846154 ='s Smoothing Factor really appreciate help (3 Replies)
Discussion started by: harte
3 Replies

6. OS X (Apple)

Check file sequence script not working. Need help.

I have a script to check a file sequence for missing frames. It used to work in true Unix but now on OSX 10.6.4 (bash) it reports every frame is missing. Hopefully someone here can help. #!/bin/csh -f if ($#argv < 1) then echo echo "Usage: checkseq <name> " echo... (3 Replies)
Discussion started by: scribling
3 Replies

7. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

8. Shell Programming and Scripting

Help Syntax Shell-Script

Hi Guys, iīve a question ... but itīs a litte bit tricky: iīve a 3 php-scripts which runīs via cron at night. These script reads an xml-file a writes it in an MySQL-DB. I named them (for example here ) Script1 - Script3. The XML-Files i named xml1 - xml3. Now, iīve build a Batch-file,... (10 Replies)
Discussion started by: jackcracker
10 Replies

9. Shell Programming and Scripting

How to Check Shell script syntax w/o executing

Hello All, I looking for a way to verify the correction of shell script syntax. Is there any switch like -c in perl which do this in shell ? Thank You. (1 Reply)
Discussion started by: Alalush
1 Replies

10. Shell Programming and Scripting

Shell script syntax checker

I have a rather big script that i have written in ksh and it is falling over in two places with a 'test argument' error. I know this usually means that the if statement is not correct, but it is fine. I have looked through the rest of the script for any odd brackets or ` marks, but can't see... (2 Replies)
Discussion started by: handak9
2 Replies
Login or Register to Ask a Question