<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: `if' is not matched - message in shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814919#M85276</link>
    <description>Hi Christian,&lt;BR /&gt;You need to ftp the script to your server as ASCII, not binary. The ^M is a typical conversion error.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom</description>
    <pubDate>Fri, 27 Sep 2002 12:33:02 GMT</pubDate>
    <dc:creator>Tom Geudens</dc:creator>
    <dc:date>2002-09-27T12:33:02Z</dc:date>
    <item>
      <title>`if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814912#M85269</link>
      <description>Hi gurus,&lt;BR /&gt;&lt;BR /&gt;I am quite new to hp-ux and have the following problem:&lt;BR /&gt;I try using a simple if then else fi loop in a shell script under HP-UX 10.20&lt;BR /&gt;when I copy and past the code in a shell window everything works: &lt;BR /&gt;&lt;BR /&gt;# if [ -f /home/vanadm/checkspace ] &lt;BR /&gt;&amp;gt;    then&lt;BR /&gt;&amp;gt;       echo yes&lt;BR /&gt;&amp;gt;    else&lt;BR /&gt;&amp;gt;       echo no&lt;BR /&gt;&amp;gt;    fi&lt;BR /&gt;no&lt;BR /&gt;&lt;BR /&gt;but when I try to run it as shell script (the code above saved in /home/vanadm/iftest) I get two errors:&lt;BR /&gt;&lt;BR /&gt;1.&lt;BR /&gt;if the first script line contains a: #!/sbin/sh  or #!/usr/bin/sh&lt;BR /&gt;I get:&lt;BR /&gt;# /home/vanadm/iftest&lt;BR /&gt;script interpreter "/usr/bin/sh" not found&lt;BR /&gt;sh: /home/vanadm/iftest:  not found.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2. &lt;BR /&gt;if I remove the #!/xxx line the script is executed and returns:&lt;BR /&gt;# /home/vanadm/iftest&lt;BR /&gt;/home/vanadm/iftest: Syntax error at line 1 : `if' is not matched.&lt;BR /&gt;&lt;BR /&gt;I am root, all files are rwxrwxrwx, and /usr/bin/sh _is_there_ ! ;-)&lt;BR /&gt;This `if' is not matched. drives me crazy. I tried the if [ xxx ] and the if test xxx syntax with no difference&lt;BR /&gt;I tried using multiple lines as above and a one-liner (if ; then ; else ; fi) - with no difference too&lt;BR /&gt;&lt;BR /&gt;What specific Posix-Shell problem do I miss? (however, the problem remains the same using csh)&lt;BR /&gt;&lt;BR /&gt;Thanks for any help&lt;BR /&gt;&lt;BR /&gt;Christian Vollma</description>
      <pubDate>Fri, 27 Sep 2002 11:50:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814912#M85269</guid>
      <dc:creator>Christian Vollmar</dc:creator>
      <dc:date>2002-09-27T11:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814913#M85270</link>
      <description>Christian,&lt;BR /&gt;&lt;BR /&gt;Can you put the entire listing of the script in a posting?&lt;BR /&gt;&lt;BR /&gt;We can then have a look at the actual code. My personal style for testing conditions such as file existing is to use double square brackets - however I do not know if that affects the result you get.&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Fri, 27 Sep 2002 12:02:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814913#M85270</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2002-09-27T12:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814914#M85271</link>
      <description>Hi Christian,&lt;BR /&gt;             the unmatched if-error indicates that the shell cannot "see" the rest of the if- sentence, in particular not the "fi". It probably derives from your cut and paste where you probably paste some garbage into the script as well. Could you please try and write it manually in a fresh file?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Sep 2002 12:10:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814914#M85271</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-09-27T12:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814915#M85272</link>
      <description>Hi Christian,&lt;BR /&gt;That is indeed strange ... the same script seems to work for me.&lt;BR /&gt;I've attached it. Can you execute it with&lt;BR /&gt;sh -x iftest.sh&lt;BR /&gt;and post the output ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom</description>
      <pubDate>Fri, 27 Sep 2002 12:11:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814915#M85272</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-09-27T12:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814916#M85273</link>
      <description>Try using #!/bin/sh as your first line. The specific code your referenced looks good enough.&lt;BR /&gt;&lt;BR /&gt;Craig</description>
      <pubDate>Fri, 27 Sep 2002 12:11:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814916#M85273</guid>
      <dc:creator>UNIX Engr</dc:creator>
      <dc:date>2002-09-27T12:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814917#M85274</link>
      <description>Hi Ian,&lt;BR /&gt;&lt;BR /&gt;whow, thats a response time!&lt;BR /&gt;&lt;BR /&gt;The complete code is stored in /home/vanadm/iftest:&lt;BR /&gt;&lt;BR /&gt;if [ -f /home/vanadm/checkspace ] &lt;BR /&gt;   then&lt;BR /&gt;       echo yes&lt;BR /&gt;   else&lt;BR /&gt;       echo no&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;I have just tried double brackets an things changed to&lt;BR /&gt;&lt;BR /&gt;' is not expected.rror at line 2 : `&lt;BR /&gt;&lt;BR /&gt;(No mistyping, this is an exact paste from the shell window!)&lt;BR /&gt;There still seems to be a syntax problem!?!!&lt;BR /&gt;&lt;BR /&gt;The problem does not depend on the condition I test, I tried several tests.&lt;BR /&gt;&lt;BR /&gt;regs n thnx&lt;BR /&gt;&lt;BR /&gt;Christian</description>
      <pubDate>Fri, 27 Sep 2002 12:19:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814917#M85274</guid>
      <dc:creator>Christian Vollmar</dc:creator>
      <dc:date>2002-09-27T12:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814918#M85275</link>
      <description>Hi Tom &amp;amp; John&lt;BR /&gt;&lt;BR /&gt;I have just used Toms script in a fresh file (and my editor shows that there are no foreign characters or other garbage)&lt;BR /&gt;Here is the result:&lt;BR /&gt;&lt;BR /&gt;# sh -x iftest.sh&lt;BR /&gt;+ [ -f /home/sys/checkspace ] &lt;BR /&gt;iftest.sh: test: A ] character is missing.&lt;BR /&gt;+ &lt;BR /&gt;iftest.sh[4]: ^M:  not found.&lt;BR /&gt;+ echo no &lt;BR /&gt;no &lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt;Any more ideas?</description>
      <pubDate>Fri, 27 Sep 2002 12:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814918#M85275</guid>
      <dc:creator>Christian Vollmar</dc:creator>
      <dc:date>2002-09-27T12:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814919#M85276</link>
      <description>Hi Christian,&lt;BR /&gt;You need to ftp the script to your server as ASCII, not binary. The ^M is a typical conversion error.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom</description>
      <pubDate>Fri, 27 Sep 2002 12:33:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814919#M85276</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-09-27T12:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814920#M85277</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;try to do a ux2dos on the script and try again.&lt;BR /&gt;&lt;BR /&gt;dos2ux &lt;INFILE&gt;outfile &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj&lt;/INFILE&gt;</description>
      <pubDate>Fri, 27 Sep 2002 12:37:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814920#M85277</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2002-09-27T12:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814921#M85278</link>
      <description>Hi again,&lt;BR /&gt;can you confirm that you actually typed the code manually?&lt;BR /&gt;   Sorry, I have to ask, but your last response hints that you did not.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Fri, 27 Sep 2002 12:40:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814921#M85278</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-09-27T12:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814922#M85279</link>
      <description>oops!&lt;BR /&gt;sorry should have said "dos2ux"&lt;BR /&gt;&lt;BR /&gt;dos2ux &lt;IFTEST&gt;iftest2 &lt;BR /&gt;&lt;/IFTEST&gt;</description>
      <pubDate>Fri, 27 Sep 2002 12:40:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814922#M85279</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2002-09-27T12:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814923#M85280</link>
      <description>Hi Tom&lt;BR /&gt;&lt;BR /&gt;the good message is: Is was the ftp-transfer!&lt;BR /&gt;the bad one ist that i didnt think about this first. &lt;BR /&gt;I never had problems with this before and the "tranfer mode auto" button in my ftp client always worked well - until yesterday&lt;BR /&gt;&lt;BR /&gt;Thanks for opening my eyes ;-) This has saved my weekend - enjoy yours!&lt;BR /&gt;&lt;BR /&gt;Is there a way to detect such problems in a file, cat and more showed the correct code?</description>
      <pubDate>Fri, 27 Sep 2002 12:45:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814923#M85280</guid>
      <dc:creator>Christian Vollmar</dc:creator>
      <dc:date>2002-09-27T12:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814924#M85281</link>
      <description>OK if you want to strip out the control chars, you can also do a 'strings' command of the file.&lt;BR /&gt;&lt;BR /&gt;strings chartest1 &amp;gt;chartest2&lt;BR /&gt;&lt;BR /&gt;Does any conditional work? How about a numeric test?&lt;BR /&gt;&lt;BR /&gt;export TEST=1&lt;BR /&gt;if (( $TEST == 1 ))&lt;BR /&gt;then&lt;BR /&gt;     print "test is one"&lt;BR /&gt;else&lt;BR /&gt;     print "test not one"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;I would be tempted to look at environment variables and the shell you are using. Can you tell us which shell you are logged in as, and what the output of the 'env' statement is?&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Fri, 27 Sep 2002 12:50:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814924#M85281</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2002-09-27T12:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814925#M85282</link>
      <description>Hi Christian,&lt;BR /&gt;&lt;BR /&gt;Use the view command (readonly vi) - that will show you the ^M character.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Fri, 27 Sep 2002 12:52:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814925#M85282</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-09-27T12:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814926#M85283</link>
      <description>If you used "vi" to edit the file it would show any "control" characters including ^M.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 27 Sep 2002 12:54:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814926#M85283</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-09-27T12:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814927#M85284</link>
      <description>Hi Christian,&lt;BR /&gt;&lt;BR /&gt;Sounds like you are editing your scripts / files on a PC then transferring them to UNIX.  This is common for new UNIX users.  If so, I suggest you bite the bullet and learn vi.  It's not the world's most user-friendly text editor, especially if you're used to a word processor on your PC, however it's available on every "UNIX like" system whether you use a GUI or not.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Fri, 27 Sep 2002 12:58:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814927#M85284</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-09-27T12:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814928#M85285</link>
      <description>Hi Christian:&lt;BR /&gt;&lt;BR /&gt;Yet another way to view control characters in a file is with 'cat -vt'.  A carriage return shows as ^M and a tab character appears as ^I.&lt;BR /&gt;&lt;BR /&gt;A useful reference is 'man ascii(5)'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 27 Sep 2002 13:02:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814928#M85285</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-27T13:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814929#M85286</link>
      <description>You got me! &lt;BR /&gt;Indeed I edited the files on an PC and transferred them to the HP - this worked fine for all the etc/*s and other config files I had to edit during the last weeks.&lt;BR /&gt;I even started with vi and use it every time when i am at the HP-box, but it runs a EEG-recording software 24/7 and is occupied by a technician most time, so I hav to use telnet. And vi causes problems with my telnet client (CRT for Win) - so I used a Win-Editor with built-in ftp-client.&lt;BR /&gt;&lt;BR /&gt;Well at least I am now aware of the problem - strange that it didnt appear earlier ;-)&lt;BR /&gt;&lt;BR /&gt;Thanks to all of you and enjoy your weekend&lt;BR /&gt;&lt;BR /&gt;Christia</description>
      <pubDate>Fri, 27 Sep 2002 13:13:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814929#M85286</guid>
      <dc:creator>Christian Vollmar</dc:creator>
      <dc:date>2002-09-27T13:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814930#M85287</link>
      <description>Many systems will ignore a trailing ^M, but I would recommend you go back and fix those /etc files anyway... Just in case...&lt;BR /&gt;&lt;BR /&gt;my 2 cents&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 27 Sep 2002 13:17:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814930#M85287</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-09-27T13:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: `if' is not matched - message in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814931#M85288</link>
      <description>Hi Christian,&lt;BR /&gt;I noticed you're pretty new to the forums. May I point out the following link ?&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x022718276953d61190040090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x022718276953d61190040090279cd0f9,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This explains (amongst other things) about the points system.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Fri, 27 Sep 2002 13:22:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-is-not-matched-message-in-shell-script/m-p/2814931#M85288</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-09-27T13:22:40Z</dc:date>
    </item>
  </channel>
</rss>

