<?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: Need help on TCL scripts in Operating System - Microsoft</title>
    <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200859#M11081</link>
    <description>Hello matthew!&lt;BR /&gt;&lt;BR /&gt;You can access all the traditional regexps in TCL, plus AREs, which include some extra definitions.&lt;BR /&gt;&lt;BR /&gt;To read in lines 20 to 60 in a script and process each line using patterns you could easily:&lt;BR /&gt;&lt;BR /&gt;set fd [open "file_name" "r"]&lt;BR /&gt;# Slurp file contents&lt;BR /&gt;set lines [split [read $fd] "\n"]&lt;BR /&gt;close $fd&lt;BR /&gt;# Get lines 20 - 60 inclusive&lt;BR /&gt;set lines [lrange $lines 20 60]&lt;BR /&gt;&lt;BR /&gt;# Operate on lines&lt;BR /&gt;foreach line $lines {&lt;BR /&gt;# Use regexp to match lines by pattern&lt;BR /&gt;# Use regsub to substitute by pattern&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The exact syntax and regexp rules are described here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm" target="_blank"&gt;http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Kobylka</description>
    <pubDate>Sun, 27 Sep 2009 15:29:11 GMT</pubDate>
    <dc:creator>kobylka</dc:creator>
    <dc:date>2009-09-27T15:29:11Z</dc:date>
    <item>
      <title>Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200855#M11077</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;can I use sed operation in tcl scripts ? &lt;BR /&gt;&lt;BR /&gt;Need to get line 20 to line 60.&lt;BR /&gt;Pattern might be vary. &lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Sun, 27 Sep 2009 13:47:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200855#M11077</guid>
      <dc:creator>Matthew_50</dc:creator>
      <dc:date>2009-09-27T13:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200856#M11078</link>
      <description>Hi Matthew:&lt;BR /&gt;&lt;BR /&gt;Since TCL scripts are whitespace-delimited strings terminated by a newline or semicolon, they are appropriate text files for use by standard tools like 'sed', 'awk', Perl, etc.&lt;BR /&gt;&lt;BR /&gt;As always, when in doubt, TRY IT! :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 27 Sep 2009 13:52:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200856#M11078</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-27T13:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200857#M11079</link>
      <description>Hi (again) Matthew:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Need to get line 20 to line 60. Pattern might be vary.&lt;BR /&gt;&lt;BR /&gt;I suppose that that really was your question.  You can do:&lt;BR /&gt;&lt;BR /&gt;# sed -ne '20,60p' file&lt;BR /&gt;&lt;BR /&gt;THe '-n' turns off printing.  The '-e' says the script follows.  The '20.60p' says from line-20 (one-relative) through line-60 print ('p').&lt;BR /&gt;&lt;BR /&gt;If you wanted to do the same not knowing line-numbers but knowing patterns that mark the lines you want, you could do:&lt;BR /&gt;&lt;BR /&gt;# sed -ne '/pattern1/,/pattern2/p' file &lt;BR /&gt;&lt;BR /&gt;Notice that the regular expression to match is enclosed in forward slashes, with a common again signifying a range.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Sep 2009 14:19:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200857#M11079</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-27T14:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200858#M11080</link>
      <description>hmm, due the customer enviornment is windows, try to solve this in perl, &lt;BR /&gt;&lt;BR /&gt;but wondering, in pervious perl which you had provide, &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my ( @first, @second, $slot, $n );&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    next if /^===/;&lt;BR /&gt;    if (m{^\s*\d}) {&lt;BR /&gt;        @first = split;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (m{^slot}) {&lt;BR /&gt;        @second = split;&lt;BR /&gt;        $slot   = shift @second;&lt;BR /&gt;        ( $slot = shift @second ) =~ s/://;&lt;BR /&gt;    }&lt;BR /&gt;    if ( m{^\s*$} or eof ) {&lt;BR /&gt;        for ( $n = 0; $n &amp;lt; @first; $n++ ) {&lt;BR /&gt;            print $slot, '/', $first[$n],' ',$second[$n],"\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;I need to check if $second[$n] contain k or m, if contain k, then $second[$n], exclude the string k, and multiplier 1000, if contain m, then exclude the string m, and multiplier 1000000, if not contain k either m, print, any suggestion ?&lt;BR /&gt;&lt;BR /&gt;originally, I would like to combine tcl with expect module to get the input, (perl in windows do not have expect), then call perl script to handle to reformat, then called cygwin to process the numbers to re-print the result, &lt;BR /&gt;&lt;BR /&gt;don't know if there have any other quick way which not to install too many extra application on windows system. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Sep 2009 15:16:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200858#M11080</guid>
      <dc:creator>Matthew_50</dc:creator>
      <dc:date>2009-09-27T15:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200859#M11081</link>
      <description>Hello matthew!&lt;BR /&gt;&lt;BR /&gt;You can access all the traditional regexps in TCL, plus AREs, which include some extra definitions.&lt;BR /&gt;&lt;BR /&gt;To read in lines 20 to 60 in a script and process each line using patterns you could easily:&lt;BR /&gt;&lt;BR /&gt;set fd [open "file_name" "r"]&lt;BR /&gt;# Slurp file contents&lt;BR /&gt;set lines [split [read $fd] "\n"]&lt;BR /&gt;close $fd&lt;BR /&gt;# Get lines 20 - 60 inclusive&lt;BR /&gt;set lines [lrange $lines 20 60]&lt;BR /&gt;&lt;BR /&gt;# Operate on lines&lt;BR /&gt;foreach line $lines {&lt;BR /&gt;# Use regexp to match lines by pattern&lt;BR /&gt;# Use regsub to substitute by pattern&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The exact syntax and regexp rules are described here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm" target="_blank"&gt;http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Kobylka</description>
      <pubDate>Sun, 27 Sep 2009 15:29:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200859#M11081</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-27T15:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200860#M11082</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; hmm, due the customer enviornment is windows, try to solve this in perl, but wondering, in pervious perl which you had provide,&lt;BR /&gt;&lt;BR /&gt;Wait.  Let's regroup!  This thread specifically asked about 'sed'.  I answered that.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; originally, I would like to combine tcl with expect module to get the input, (perl in windows do not have expect), then call perl script to handle to reformat, then called cygwin to process the numbers to re-print the result...don't know if there have any other quick way which not to install too many extra application on windows system.&lt;BR /&gt;&lt;BR /&gt;Your real objective isn't clear.  If the core issue is being able to munge text files on a Windows system, Perl is definitely the tool in my opinion.  If your objective only needs to be met once, then you might be best servered by copying the source data to a Unix platform; massaging it; and copying ib back to the "other" environment.&lt;BR /&gt;&lt;BR /&gt;As for the un-related (?) question you raised regarding your previous post and the Perl script I provided, any further discussion of that is best raised if you re-open _taht_ thread.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Sep 2009 15:35:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200860#M11082</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-27T15:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200861#M11083</link>
      <description>extract 17 - 57, &lt;BR /&gt;&lt;BR /&gt;idealy to use, &lt;BR /&gt;&lt;BR /&gt;perl -ne 'print 17 .. 57' show.log&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Sep 2009 15:36:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200861#M11083</guid>
      <dc:creator>Matthew_50</dc:creator>
      <dc:date>2009-09-27T15:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200862#M11084</link>
      <description>Hi (again) Matthew:&lt;BR /&gt;&lt;BR /&gt;If it helps, the 'sed' commands convert to Perl very easily:&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print if 20..60' file&lt;BR /&gt;&lt;BR /&gt;# perl -ne ''print if /pattern1/../patern2/'&lt;BR /&gt;&lt;BR /&gt;As before (with 'sed') the first line of a file is numbered one.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 27 Sep 2009 15:47:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200862#M11084</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-27T15:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on TCL scripts</title>
      <link>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200863#M11085</link>
      <description>Thanks to kobylka&lt;BR /&gt;&lt;BR /&gt;set fd [open "show.log" "r"]&lt;BR /&gt;set lines [split [read $fd] "\n"]&lt;BR /&gt;close $fd&lt;BR /&gt;&lt;BR /&gt;set lines [lrange $lines 16 56]&lt;BR /&gt;foreach line $lines {puts $line}</description>
      <pubDate>Sun, 27 Sep 2009 20:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-microsoft/need-help-on-tcl-scripts/m-p/5200863#M11085</guid>
      <dc:creator>Matthew_50</dc:creator>
      <dc:date>2009-09-27T20:29:57Z</dc:date>
    </item>
  </channel>
</rss>

