Correcting script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Correcting script
# 1  
Old 12-30-2004
Correcting script

Hi!

I have for example a script/file:

+1 echo "toto"
+2 echo "abcdef
+3 echo "dqmsl" $r "dsqlfj"
+4 cat titi | tr \t' ';'
+5 exit

---------------------------------------

I try to find a solution who say:

<ERROR>
The character " has been forgotten a the line 2
The character ' has been forgotten at the line 4

I don't know if you anderstand what I say, but if:
2 or 4 or 6 or 8 or ..... characters " in a line => It is OK
1 or 3 or 5 or 7 or ..... characters " in a line => ERROR! character forgotten

It is the same for ' and `

I think a grep solution exist to recupere the number of character but I don't find it....

Thinks for your help!!! Smilie

Last edited by Castelior; 12-30-2004 at 11:34 AM..
# 2  
Old 12-30-2004
Take a look at your usage of quotes in line 2. You never close the quotes.

Should be:

Quote:
echo "abcdef"
You have a similar error in line 4
# 3  
Old 12-30-2004
I know this...

I search to do a script which correct my others scripts.
The previous script is a example of script with errors to understand what I want.
# 4  
Old 12-30-2004
Why not post your search script or at least the line(s) that is giving you problems. Are we supposed to guess what your code is doing? Smilie
# 5  
Old 12-30-2004
Quote:
cat titi | tr \t' ';'

should be

Quote:
cat titi | tr '\t' ';'
# 6  
Old 12-30-2004
If your beef is with quoting, take a look at this , this , and most definitely this.

Cheers
ZB
# 7  
Old 12-30-2004
You can use the -n option to perform a syntax check for ksh and bash scripts, e.g...
Code:
bash -n script1

script1: line 3: unexpected EOF while looking for matching `"'
script1: line 6: syntax error: unexpected end of file

Or you could use awk...
Code:
awk '
   BEGIN {
      FS = "[\042\047]"
   }
   NF%2 == 0 {
      printf "%s: line %d: odd quotes: %s\n", FILENAME, NR, $0
   }
' script1

script1: line 2: odd quotes: echo "abcdef
script1: line 4: odd quotes: cat titi | tr \t' ';'

Last edited by Ygor; 01-02-2005 at 12:16 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

2. Shell Programming and Scripting

Correcting awk error

the following code turns back ticks "`" to new lines "\n". Then, it attempts to grab only a certain section of the output and excludes lines that contain particular patterns...i.e. "ZooLine|echo|opencert". awk -vs1="\`" '{gsub(s1,"\n",$0)} 1 {print ; if(/NewLine \(\)/,/}/{if(!/NewLine|echo... (3 Replies)
Discussion started by: SkySmart
3 Replies

3. Shell Programming and Scripting

Need help in correcting sed script

Hi All, I have a big configuration log where I want to change string "aaa" to "bbb" under auto-config-policy only right after "deny", "accept" and "hold" strings, nowhere else. <<<< text >>>>> auto-config-policy test deny aaa precedence 4 profile aaa any deny aaa... (4 Replies)
Discussion started by: temp.sha
4 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Help correcting file with differing number of fields

Hi all, I have a tab separated file, and one of the fields is sub-delimited by colon. The problem is there can be zero to 4 colons within this field. When I try to change colons to tabs the result is a file with a differing number of fields. I want to go from: a:b:c:d:e a:b:c a:b:c:d:e a... (4 Replies)
Discussion started by: torchij
4 Replies

5. Shell Programming and Scripting

need help in correcting the code

Hi Guys ! can anyone help me to write the code doing same thing without using awk. is it possible using cut command? awk '{c++} END {for(k in c} print k "\t\t" c;}' file_name | sort -nrk 2 | column -t thanks in advance BR Ewa (4 Replies)
Discussion started by: me_newbie
4 Replies

6. UNIX Desktop Questions & Answers

Correcting the display resolution

I have an issue with the display resolution under Xfce. The monitor can handle 1024x768, but the screen display is 800x600. The control panel does not allow me to change this. I also found the file .config/xfce4/xfconf/xfce-perchannel-xml/displays.xml in which I have made changes, but after a... (0 Replies)
Discussion started by: figaro
0 Replies

7. AIX

Help me in correcting sendmail.cf

Hi all, In AIX I need to set the below two as of now these are not. 1)Opnoexpn is not set in sendmail.cf 2)Opnovrfy is not set in sendmail.cf Please let me know the steps to set Opnoexpn and Opnovrfy in sendmail.cf Thanks and Regards, Pavankumar (0 Replies)
Discussion started by: pavankumar432
0 Replies

8. UNIX for Dummies Questions & Answers

Correcting the time on FreeBSD

Possibly this is not even a FreeBSD issue, but a BIOS issue. Upon installation of FreeBSD, the time is set using the standard feature of selecting a time zone. Some installations are correctly set to the current time, but others are either one or two hours off. So the time is read from the time... (0 Replies)
Discussion started by: figaro
0 Replies

9. Solaris

Correcting system time

I've installed Solaris 8, but didn't quite give it the correct (machine) time. Think the machine is out of sync. Can I change that afterwards or do I have to do another install right from the beginning? (1 Reply)
Discussion started by: kuultak
1 Replies
Login or Register to Ask a Question

Featured Tech Videos