<?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: Checking script parameter (Respecting a mask) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922075#M495263</link>
    <description>&lt;P&gt;&amp;nbsp;&amp;nbsp; One possible way, using "sed" [*]:&lt;/P&gt;&lt;P&gt;mba$ p1='[0-9][0-9]_[0-9][0-9]_[0-9][0-9][0-9][0-9]_'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Part 1.&lt;BR /&gt;mba$ p2='[0-9][0-9]_[0-9][0-9]_[0-9][0-9]_[0-9][0-9][0-9][0-9]' # Part 2.&lt;/P&gt;&lt;P&gt;mba$ g1='erveurX120_11_2016_23_55_55_0200_commentZ21' # Good string.&lt;BR /&gt;mba$ b1='erveurX120_11_2016_23_55_55_02o0_commentZ21' # Bad string.&lt;/P&gt;&lt;P&gt;mba$ echo "${g1}" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;20_11_2016_23_55_55_0200&lt;/P&gt;&lt;P&gt;mba$ echo "${b1}" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;erveurX120_11_2016_23_55_55_02o0_commentZ21&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; If this "sed" command returns the original string, then the&lt;BR /&gt;NN_NN_NNNN_NN_NN_NN_NNNN pattern was not matched.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; The "..*" parts here require at least one non-pattern character&lt;BR /&gt;before and after the pattern.&amp;nbsp; As usual in such situations, many things&lt;BR /&gt;are possible, and you must decide exactly what you wish to accept and&lt;BR /&gt;reject.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [*] As I always say, if you can't do it with "sed", then it doesn't&lt;BR /&gt;need doing.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2016 12:58:48 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2016-11-30T12:58:48Z</dc:date>
    <item>
      <title>Checking script parameter (Respecting a mask)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922035#M495262</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my script accept only one parameter&lt;/P&gt;&lt;P&gt;./myscript.ksh param1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to write a routine to check and validate the parameter first priot to actions and this parameter needs to contain at least something matching &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;NN_NN_NNNN_NN_NN_NN_NNNN&lt;/STRONG&gt;&lt;/FONT&gt; format. Where N is digit between 0 and 9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;myscript.ksh serveurX1&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;20_11_2016_23_55_55_0200&lt;/STRONG&gt;&lt;/FONT&gt;_commentZ21&lt;/P&gt;&lt;P&gt;myscript.ksh magic100&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;20_11_2016_23_55_55_0200&lt;/STRONG&gt;&lt;/FONT&gt;_commentZ23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, how to be sure that something matching &lt;FONT color="#0000FF"&gt;NN_NN_NNNN_NN_NN_NN_NNNN&lt;/FONT&gt; is part of the parameter ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is very welcome, any idea here ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Den&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 11:02:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922035#M495262</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2016-11-30T11:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Checking script parameter (Respecting a mask)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922075#M495263</link>
      <description>&lt;P&gt;&amp;nbsp;&amp;nbsp; One possible way, using "sed" [*]:&lt;/P&gt;&lt;P&gt;mba$ p1='[0-9][0-9]_[0-9][0-9]_[0-9][0-9][0-9][0-9]_'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Part 1.&lt;BR /&gt;mba$ p2='[0-9][0-9]_[0-9][0-9]_[0-9][0-9]_[0-9][0-9][0-9][0-9]' # Part 2.&lt;/P&gt;&lt;P&gt;mba$ g1='erveurX120_11_2016_23_55_55_0200_commentZ21' # Good string.&lt;BR /&gt;mba$ b1='erveurX120_11_2016_23_55_55_02o0_commentZ21' # Bad string.&lt;/P&gt;&lt;P&gt;mba$ echo "${g1}" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;20_11_2016_23_55_55_0200&lt;/P&gt;&lt;P&gt;mba$ echo "${b1}" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;erveurX120_11_2016_23_55_55_02o0_commentZ21&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; If this "sed" command returns the original string, then the&lt;BR /&gt;NN_NN_NNNN_NN_NN_NN_NNNN pattern was not matched.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; The "..*" parts here require at least one non-pattern character&lt;BR /&gt;before and after the pattern.&amp;nbsp; As usual in such situations, many things&lt;BR /&gt;are possible, and you must decide exactly what you wish to accept and&lt;BR /&gt;reject.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [*] As I always say, if you can't do it with "sed", then it doesn't&lt;BR /&gt;need doing.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 12:58:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922075#M495263</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-11-30T12:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Checking script parameter (Respecting a mask)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922103#M495264</link>
      <description>&lt;P&gt;Hi Steven,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much, it works perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Den.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 13:49:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922103#M495264</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2016-11-30T13:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Checking script parameter (Respecting a mask)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922104#M495266</link>
      <description>&lt;P&gt;Almost OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you mention, it cannot work with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaaa10_10_2017_23_12_22_0004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10_10_2017_23_12_22_0004eeee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10_10_2017_23_12_22_0004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alll these strings are respecting the mask.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could add systematically Z before and Z after for my test. Correct ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards, Den.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 14:12:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922104#M495266</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2016-11-30T14:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Checking script parameter (Respecting a mask)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922228#M495267</link>
      <description>&lt;P&gt;&amp;gt; The "..*" parts here require at least one non-pattern character&lt;BR /&gt;&amp;gt; before and after the pattern. [...]&lt;/P&gt;&lt;P&gt;&amp;gt; I could add systematically Z before and Z after for my test. Correct ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Sure.&lt;/P&gt;&lt;P&gt;mba$ g2='aaaa10_10_2017_23_12_22_0004'&lt;BR /&gt;mba$ g3='10_10_2017_23_12_22_0004eeee'&lt;BR /&gt;mba$ g4='10_10_2017_23_12_22_0004'&lt;/P&gt;&lt;P&gt;mba$ echo "Z${g1}Z" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;20_11_2016_23_55_55_0200&lt;/P&gt;&lt;P&gt;mba$ echo "Z${g2}Z" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;10_10_2017_23_12_22_0004&lt;/P&gt;&lt;P&gt;mba$ echo "Z${g3}Z" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;10_10_2017_23_12_22_0004&lt;/P&gt;&lt;P&gt;mba$ echo "Z${g4}Z" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;10_10_2017_23_12_22_0004&lt;/P&gt;&lt;P&gt;mba$ echo "Z${b1}Z" | sed -e "s/..*\(${p1}${p2}\)..*/\1/"&lt;BR /&gt;ZerveurX120_11_2016_23_55_55_02o0_commentZ21Z&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; That way, the result from every bad string, and no good string, will&lt;BR /&gt;begin (and end) with "Z".&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 18:15:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-script-parameter-respecting-a-mask/m-p/6922228#M495267</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-11-30T18:15:32Z</dc:date>
    </item>
  </channel>
</rss>

