Jump to content
 English      
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
     Forums advanced search
HP.com Home
IT Resource Center Forums > OpenVMS > general

Global replace for many command procedures...?

» 

IT Resource Center

» Login
» Register
» My profile
» Search knowledge base
» Forums
» Patch database
» Download drivers, software and firmware
» Warranty check
» Support Case Manager
» Software Update Manager
» Training and Education
» More maintenance and support options
» Online help
» Site map

Member icons
 
 HP moderator  HP moderator
 Expert in this area  Expert in this area
Member status
ITRC Pro ITRC Pro
250 points
ITRC Graduate ITRC Graduate
500 points
ITRC Wizard ITRC Wizard
1000 points
ITRC Royalty ITRC Royalty
2500 points
ITRC Pharaoh ITRC Pharaoh
7500 points
Olympian Olympian
20000 points
1-Star Olympian 1-Star Olympian
40000 points
2-Star Olympian 2-Star Olympian
80000 points
»  How to earn points
»  Support forums FAQs
Question status
Magical answer Magical answer
Message with a response that solved the author's question
Favorites status
Add to my favorites Add to my favorites
Delete from my favorites Delete from my favorites
This thread has been closed Thread closed
 

Content starts here
   Create a new message    Receive e-mail notification if a new reply is posted  Reply to this message
Author Subject: Global replace for many command procedures...?      Add to my favorites
ChaimBu
May 29, 2006 04:03:44 GMT   

We have many command procedures, and we need to make a global modification in all of them (one particular string need be replaced by a different string). Is there an elegant method of accomplishing this without having to individually edit each and every one of them.

Thanks,

Chaim
Note: If you are the author of this question and wish to assign points to any of the answers, please login first.For more information on assigning points ,click here


Sort Answers By: Date or Points
Wim Van den Wyngaert This member has accumulated 7500 or more points
May 29, 2006 04:26:35 GMT  5 pts

I normally take a buffer in EVE in which all files are listed that need modif. Then I use LEARN to get the file, do the change and save it. Then replay it "number of files" times.

Very handy since any edit session can be done (but keep in mind that the edits must be applicable to all source files). If it goes wrong, delete/sin will save you.

Wim
Karl Rohwedder This member has accumulated 2500 or more points
May 29, 2006 04:29:35 GMT  8 pts

HP engineering has released the FIND kit (via freeware V7.0, see VMS site). Beside just FIND it has also FIND/REPLACE, which works quite well (incl. regular expressions).

regards Kalle
ChaimBu
May 29, 2006 05:29:00 GMT    N/A: Question Author

Kalle,

Could you please place a link to the VMS site as I am not yet familiar with this.

Thanks,

Chaim
Karl Rohwedder This member has accumulated 2500 or more points
May 29, 2006 05:40:10 GMT  8 pts

Chaim,

here it is:

http://h71000.www7.hp.com/freeware/freeware70/find/

regards Kalle
ChaimBu
May 29, 2006 05:52:43 GMT    N/A: Question Author

Kalle,

Thanks!

Please excuse my "ignorance". I downloaded this to my PC. WHat is this file? How do I use it on the VMS system?

Thanks,

Chaim
Karl Rohwedder This member has accumulated 2500 or more points
May 29, 2006 07:04:05 GMT  8 pts

Chaim,

this is a kitfile for the PCSI utility on VMS. The PCSI Utility (Commandverb PRODUCT) is used to install, reconfigure... software products on VMS. It replaced the older VMSINSTAL DCL-procedure. The doc-set contains more information about PCSI.

You should transfer this file onto your VMS system in binary mode. To install the FIND utility pls. issue:

$ PRODUCT INSTALL FIND

and answer any questions. This will install the FIND utility onto the default destination
SYS$COMMON.

If the file attributes have been corrupted during transfer, you may repair them with
$ SET FILE <name of kit>/ATT=(RFM=FIX,LRL=512,MRS=512)

regards Kalle
Joseph Huber This member has accumulated 2500 or more points
May 29, 2006 07:06:44 GMT  8 pts

.PCSI$COMPRESSED files are distributions for the PCSI utility, THE PRODUCT command.

To install the software, use the command
PRODUCT INSTALL FIND
See HELP PRODUCT for /SOURCE and /DESTINATION switches.

The file must have been transferred in BINARY mode (by HTTP download or FTP IMAGE mode).
Joseph Huber This member has accumulated 2500 or more points
May 29, 2006 10:09:19 GMT  8 pts

A global replace command using no extra program , but EDIT/EDT came from Ph.Helbig once upon a time, I edited a bit, here it is:

http://wwwvms.mppmu.mpg.de/util_root/com/gsr.com
Hein van den Heuvel Expert in this area This member has accumulated 20000 or more points
May 29, 2006 10:39:05 GMT  8 pts

So many solutions...

Using basic DCL scripting it could be done as:

------- edit_many.com -------
$ if p1.eqs."" then exit
$ wildcard_removed = p1 - "*" - "%"
$ loop:
$ file = f$searc(p1)
$ if file.eqs."" then exit
$ editx/edt/com=sys$input: 'file
s/noot/aap/%wh
exit
$ if p1.nes.wildcard_removed then goto loop


Personally I would grab perl, mostly because I never bothered to learn tpu.

I find that the regular expressions in perl are so much more desirabel to find just the right strings to replace.

Here is a perl 'one liner' for the same edit:

$ perl -p -i -e "s/old-text/new-text/g" %.tmp

-p = 'print after loop" : loop over input file stashing into default variable $_, print $_ to sys$ouput after executing perl program over each line.

-i = 'inplace' : output to same name as input

-e = 'execute this' : program text follows

s/x/y/g : no variable listed -> operate on $_, s = substitute, g = all matches on line.


Enjoy,
Hein.
Jan van den Ende Expert in this area This member has accumulated 7500 or more points
May 29, 2006 13:05:24 GMT  8 pts

Chaim,

I have always used (a variation of) Hein's DCL. It's quick, it's easy, it's foolproof.

One note of caution: please make sure of a good to-be-replaced string.
You will NOT want to replace some substring that happens to match!

If you want to make sure, extend the DCL with a DIFF/OUTP=<in some new tmp dir> after each EDIT(default: the highest 2 existing versions are compared)
Scan the DIFF output files for any UNintended changes (expect none or very few of those).

Success.

Proost.

Have one on me.

jpe
John Gillings Expert in this area This member has accumulated 7500 or more points
May 29, 2006 21:53:25 GMT  7 pts

Chaim,

Before you embark on editing, think about what you're changing and why. There may be a mechanism that means you don't need to modify any code, OR, if you must change code, you may be able to do it in such a way that future changes are much simpler.

Is the string a command (can be redefined as a symbol) or file name (might be possible to redefine as a logical name)?

If it's something that DCL won't automatically substitute, you may be able to code it so there's a manual substitution. Maybe something like this?

$ ChaimString=F$TRNLNM("ChaimStringValue")
$ IF ChaimString.EQS."" THEN ChaimString="DefaultValue"

...
$ COMMAND 'ChaimString'


Now you can change the string value by defining the logical name ChaimStringValue.
ChaimBu
May 30, 2006 00:15:17 GMT    N/A: Question Author

Hein,

I assume that the perl command assumes that there is perl on the VMS system. In our case, we do NOT have perl.

Thanks,

Chaim
Hein van den Heuvel Expert in this area This member has accumulated 20000 or more points
May 30, 2006 00:56:34 GMT  8 pts

Hey... you started it. You wrote 'elegant'

:-)

Perl is not the answer to everything, but it can make system managers and system programmer much more efficient.
For VMS based folks perl is also a great way to make themselves more valuable for non-VMS tasks (Unix, Windoze,...)

At this point each VMS system should have Perl installed IMHO (and DFU also :-).

btw... if I did write a dcl script, or a perl soltuion, I woudl probably first test whether the string is present before creating a fresh version with no changes.
In may example that could look like:

$ if p1.eqs."" then exit
$ wild = p1 - "*" - "%"
$ loop:
$ file = f$searc(p1)
$ if file.eqs."" then exit
$ search/nowarn/noout 'file noot
$ if $severity.eq.3 then goto skip_edit
$ editx/edt/com=sys$input: 'file
s/noot/aap/%wh
exit
$skip_edit:
$ if p1.nes.wild then goto loop

Cheers,
Hein.
Robert Atkinson This member has accumulated 1000 or more points
May 30, 2006 04:53:51 GMT  7 pts Attachement is 276658.TXT 

Similar command procedure (attached) that we've used for years.

Rob.
Robert Gezelter Expert in this area This member has accumulated 7500 or more points
May 30, 2006 06:12:53 GMT  7 pts

Chaim,

Personally, I use the TECO editor, which can be programmed to iterate through one or more directories, performing each change globally within a file.

The advantage of TECO, which is admittedly cryptic (unless one is used to its syntax) is that it comes as part of the base OpenVMS distribution kit on all versions of OpenVMS. Thus, it is useable without worrying about installing additional software.

- Bob Gezelter, http://www.rlgsc.com
Ruud Dijt
May 30, 2006 07:44:56 GMT  7 pts

Personal I use 2 com files: one searches for a particular string that needs to be changed, and one to do the actual change.
It shows the string found, and you can say yes or no to change that file; afterwards a difference is shown.
Edit/edt or TECO is used to do the actual change; TECO sometimes needs a temporary files to do so.

Change_all_files.com
$! VERANDER ALLE FILES
$LOOP:
$ FILE=F$SEARCH("''P1'",3)
$ IF "''FILE'" .EQS. "" THEN $ EXIT
$ NAME=F$PARSE(FILE,".COM","","name")
$ F_TYPE=F$PARSE(FILE,".COM","","TYPE")
$ F_dir=F$PARSE(FILE,".COM","","DIRECTORY")
$ F_device=F$PARSE(FILE,".COM","","Device")
$ write sys$output name,F_TYPE
$ zoek_string="check_devices.com"
$ if "''p2'" .nes. "" then $ zoek_string="''p2'"
$ SEA 'f_device''f_dir''NAME''F_TYPE' "''zoek_string'"
$ ERROR_CODE :== '$STATUS'
$ IF ERROR_CODE .EQS. "%X08D78053" THEN GOTO LOOP
$ if f$extract(0,6,name) .eqs. "CHANGE" then goto loop
$ INQUIRE ANS "Moet file ''f_device'''f_dir'''NAME'''F_TYPE' gedaan worden N/[J]
?"
$ IF ANS .EQS. "N" THEN GOTO LOOP
$ SET NOON
$@sys$login:CHANGE_FILES 'f_device''f_dir''NAME''F_TYPE'
$ GOTO LOOP
----------------------------------
change_files.com
*ht$$
$! COMMAND FILES OM backup COM FILES TE UPDATEN met de laatste check_devices
$ FILE="''P1'"
$! maak de .tec file om uit te voeren
$ open /write file update_backups.tec
$ write file "eb''file'$"
$ write file "a$"
$ write file "ncheck_devices.com$0l$"
$ write file ".,zk$ercheck_devices.com$"
$ write file "ex$$"
$ close file
$! teco = "edit\/teco"
$! teco /execute=update_backups.tec
$! of de bovenste of de onderste twee commando's uitvoeren
$! ASSIGN SYS$COMMAND SYS$INPUT
$ edit/edt 'file'
s/RECOVERY_DATA-/RECOVERY_DATA -/wh
exit
$ SET NOON
$ TEST_1=F$SEARCH("''FILE';-1")
$ SET ON
$ IF "''TEST_1'" .NES. "" THEN $ DIF 'FILE'
Peter Barkas
May 31, 2006 09:42:29 GMT  7 pts

Just in case you don't yet have enough solutions, here is a command procedure that may be useful:

http://dcl.openvms.org/search.php?query=sars&what=stories&limit=100
Bernd Fischer
May 31, 2006 10:41:20 GMT  7 pts Attachement is 276721.com 

Chaim,

just to add my .05 Cent (Euro): We're using the attached piece of TPU-Programming for years.

Regards

Bernd
Hein van den Heuvel Expert in this area This member has accumulated 20000 or more points
May 31, 2006 11:58:27 GMT  7 pts

Bernd,

Please re-reply with the attachment renamed to ".txt"

This silly Internet Exploder comes back with
"To help protect your security, Internet Explorer blocked this site from downloading files to your computer...."

Now you and I know that's a crock, but I guess we'll just have to play the game and mis-label the data, no matter how much I hate that.
[See my rant earlier today in:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1031169
:^]
Jan van den Ende Expert in this area This member has accumulated 7500 or more points
May 31, 2006 14:31:59 GMT  5 pts

Hein,

I tried to read that, but
<quote>
This page has been removed.
</quote>

:-(

Proost.

Have one on me.

jpe
Tony
Jun 2, 2006 01:39:59 GMT  7 pts

Chaim,

Here's another search and replace tool that uses DCL and TPU in one command file (see attached TXT file). Unless you want CYA files and an output file from the TPU search, I would modify the file to your desires.

In general, the command line could be:

$ @Replace P1 P2 P3 [EXACT]

where:
P1 = the desired device-dir-file-ext (s)
P2 = (optional quoted) string to search for
P3 = (optional quoted) string as replacement
P4 = Optional - EXACT, to tell TPU to search for the exact string to find or replace with so using quotes around P2 &/or P3 is required

Regards,

Tony
Tony
Jun 2, 2006 01:49:00 GMT  7 pts Attachement is 276795.TXT 

I had an issue with HP passport, so lets try to attach the DCL command file (in TXT format).

-- Tony
Bernd Fischer
Jun 8, 2006 07:18:06 GMT    Unassigned Attachement is 277034.txt 

Sorry,

forgot about the .COM-issue. Renamed version is attached.

Bernd
 
Create a new message    Receive e-mail notification if a new reply is posted   Reply to this message
 
 
Printable version
Privacy statement Using this site means you accept its terms
© 2010 Hewlett-Packard Development Company, L.P.