Is there a grep equivalent in TACL on HP-Nonstop?

973 Views Asked by At

As it says in the title; if yes, I would, of course, need a bash-like pipe in order to use it comfortably.

3

There are 3 best solutions below

0
On

If your system has OSS, you can use gtacl. gtacl allows you to start a TACL aka a Guardian program directly from OSS, which has grep natively.

To switch sessions from Guardian TACL to OSS, first type osh and then you can simply run your TACL commands via gtacl -c STATUS *, DETAIL (this is a user status example).

You can run all of your TACL commands this way while in OSS, just as you would have to run all of your osh commands for OSS as osh -c "ps -e~|egrep -e 'sshd~|prngd'" (example osh process checks ssh) when in the TACL session.

0
On

Grep does many things.

If you are looking in a specific file for a string, the command: EDIT R;LB/String/All;E

will look in single Editable files (type 101).

If you are looking in multiple files in a $. directory, there isn't any HPNonStop utility to accomplish that.

You could surround the single file example above with TACL code to look at all editable files. Something like:

FooFind

?TACL Macro
#Frame
#Push StringToFind FileName StopLoop Vol SubVol

#Set StopLoop 0
#Set StringToFind %1%
#SetMany Vol SubVol, [#Fileinfo/volume,subvol/[#Defaults/Current/ ].a]

[#If [#Empty [StringToFind]]
|then|
  #Output Usage: Please supply the string to find
  #Output EG: Foofind foo
|else|
  #Set Filename [#Defaults/Current/].a
  [#Loop
  |do|
    #Set FileName [#NextFileName [FileName]]
    [#If [#Match [Vol] [#fileinfo/Volume/[FileName]]]
     And [#Match [Subvol] [#fileinfo/Subvol/[FileName]]]
    |then|
      [#If [#Match 101 [#fileinfo/Code/[FileName]]]
      |then|
        Edit [FileName] r;lb/[StringToFind]/;Exit
      |else|
        #Output [FileName] is not an Edit file. Skipping...
      ] == end of if
    |else|
      #Set StopLoop -1
    ] == end of if
  |Until| [StopLoop]
  ] == end of loop
] == end of if
#UnFrame

Execution:

$DATA FOO 73> foofind

Usage: Please supply the string to find

EG: Foofind foo

$DATA FOO 74> foofind foo

TEXT EDITOR - T9601L01 - (20OCT14)

CURRENT FILE IS $DATA.FOO.FOO1

TEXT EDITOR - T9601L01 - (20OCT14)

CURRENT FILE IS $DATA.FOO.FOO2

1     there is a foo here

TEXT EDITOR - T9601L01 - (20OCT14)

CURRENT FILE IS $DATA.FOO.FOO3

1     And a foo foo here.

TEXT EDITOR - T9601L01 - (20OCT14)

CURRENT FILE IS $DATA.FOO.FOOFIND

   12       #Output EG: Foofind foo

$DATA.FOO.NOTEDIT is not an Edit file. Skipping...

$DATA FOO 75>

This is pretty rudimentary. There is lots of room for enhancements. But it does accomplish the task of looking for the input string in all editable files in a volume/sub-volume directory.

However, if you are looking for a grep-like utility that will search non-edit files, your best bet is to do something through a programming language.

0
On

I assume that you want to know how to search string from file by tacl

reading file to varaible

FILETOVAR file-name variable-level

exmple: FILETOVAR $AAA.BBB.CCC var
    $AAA.BBB.CCC: filename
    var: variable name

find string in var

VFIND var string

   var:variable name
   string : target string