Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Renaming lots of files using a single tacl command.

759 views
Skip to first unread message

Shiva

unread,
Jan 26, 2014, 3:54:55 AM1/26/14
to
I've lots of different file names. Not even similar ones. But say all of them are put in a single directory. And I want to change the name for all these files in this directory. Just a minor change. Like from HIJKLMNO to NEWKLMNO - to change the file names in the front, possibly - because obviously all my file names are starting in the same manner and ending differently which I would like to use to my advantage.


I'm guessing fup rename $VOL.SUBVOL.*, $VOL.SUBVOL.NEW* should work. Just that I'm not sure. Yes, I could rather try it, but I'm away at home, considering this be a weekend. Just let me know if this would work? Thank you. :)

Keith Dick

unread,
Jan 26, 2014, 7:07:36 AM1/26/14
to
Shiva wrote:
> I've lots of different file names. Not even similar ones. But say all of them are put in a single directory. And I want to change the name for all these files in this directory. Just a minor change. Like from HIJKLMNO to NEWKLMNO - to change the file names in the front, possibly - because obviously all my file names are starting in the same manner and ending differently which I would like to use to my advantage.
>
>
> I'm guessing fup rename $VOL.SUBVOL.*, $VOL.SUBVOL.NEW* should work. Just that I'm not sure. Yes, I could rather try it, but I'm away at home, considering this be a weekend. Just let me know if this would work? Thank you. :)

No, the command you suggest will not work. In the FUP RENAME command, while you can use some general wildcarding in the source position of RENAME, the only sort of wildcarding you can use in the target position is to have a subvol or a name be a single *, which means that part of the filename is copied from the corresponding part of the source. For example, you could write

FUP RENAME $VOL.SUBVOL.ABC*,$VOL.NEWSUBVL.*

Which would rename all the files in SUBVOL that begin with ABC to be in NEWSUBVL, but their names in NEWSUBVL will be the same, beginning with ABC. Files in SUBVOL whose names did not begin with ABC will not be renamed. Or you could rename everything in a subvolume:

FUP RENAME $VOL.SUBVOL.*,$VOL.NEWSUBVL.*

You can have a wildcard in the subvolume part of the source, but if you do, the filename part must be a * by itself. The manual's description of RENAME does not make this point clear, and I might not be stating the rule completely correctly, as I am just going by my recollection of what I was able to make work from time to time in the past. I'm not sure there is any fundamental reason for that restriction on the form of the source. It might just have made the implementation easier.

But none of that is what you want to do.

There might be a one-line way to do those renames from the OSS command line. You can access and rename Guardian files from OSS, and someone advanced in the art of regular expressions could, I believe, write a regular expression that expressed the renaming you want to do, but I have a feeling you cannot use such a regular expression in an OSS mv command, the command that does renames. So I think OSS cannot come to the rescue for this case, though if someone can show how to do it in a single OSS command, I'd be interested to learn how to do it.

However, there is a way to do those renames without typing each one individually. A short TACL macro can do it. If you put the following lines into an Edit file, and for sake of discussion, let's say that file is named REN:

?tacl macro
#frame
[#push fn name newname oldprefix oldlen newprefix]

[#set oldprefix %1%]
[#set oldlen [#charcount oldprefix]]
[#set newprefix %2%]

[#set fn [#filenames/maximum 1/ [oldprefix]*]]
[#loop |while| not [#empty [fn]]
|do|
[#set name [#fileinfo/file/ [fn]]]
[#set newname [name]]
[#chardel newname 1 for oldlen]
[#charins newname 1 [newprefix]]
rename [name],[newname]
[#set fn [#filenames/maximum 1,previous [fn]/ [oldprefix]*]]
]
#unframe

then you can do the renaming you want with the following command:

RUN REN HIJ NEW

If REN is in a different subvolume than the files you want to rename, just qualify the name of REN:

RUN $VOL.SUBVOL.RUN HIJ NEW

If you put REN in a subvolume that is on your PMSEARCH list, you can dispense with the RUN and qualification:

REN HIJ NEW

The TACL code above does no error checking, so it isn't a good, robust piece of code, but for a one-time job, it is good enough. Just a brief explanation: The #filenames expression gets the files that match the prefix one at a time. The other code in the loop gets the part of the filename after the last ".", removes the old prefix, adds the new prefix, then does the rename. It only works in the current subvolume, so you have to be sure your current subvolume is the one in which you want to make the change when you run it.

TACL's programming language probably is a bit different from others you have used unless you are familiar with some other macro substitution language. It takes a little getting used to, but once past the initial learning hump, it is a fairly easy language to use, and has good facilities for controlling line-mode command interfaces. The TACL Reference Manual has the complete definition of the language and all of its built-in functions. The TACL Programming Guide is intended to help you learn to use TACL's programming language.

Shiva

unread,
Jan 26, 2014, 11:20:42 PM1/26/14
to
Oh this seems harder than I thought! Ha. But Keith, I almost understand what you were trying to say there. And thank you for that amazing piece of code. That should do the job, I guess. TACL is one reason I wanted to learn more of tandem. It seemed a very powerful tool, confusing - but still powerful, and I wanted to make full use of it. Started reading the TACL reference manual, but since I'm not given much free time, it was put on hold. I work daily in the tandem environment, with changing requirements everyday. If at all, I get free time, TACL ref manual is my first priority these days. Hope I get to finish the 950 pages manual soon. And yes, some of it might not be what I want. I'll skim them out!

Also keith, say if the last two letters are what I want to change, nothing more. And say I even want to specify the exact letters that it should change to? Would that be possible in the rename command or, it needs a bit of amending in the above tack code? Sorry to trouble you with all my doubts, just that I am curious as to how much I can get out of this query.

EX: NAMEITSS to NAMEITNN

Note: Every file, consider, has SS as suffix. I want to change it to NN. Hope this should give you a clear picture. :)

harald...@benteler.de

unread,
Jan 27, 2014, 12:51:58 AM1/27/14
to
Am Sonntag, 26. Januar 2014 09:54:55 UTC+1 schrieb Shiva:
> I've lots of different file names. Not even similar ones. But say all of them are put in a single directory. And I want to change the name for all these files in this directory. Just a minor change. Like from HIJKLMNO to NEWKLMNO - to change the file names in the front, possibly - because obviously all my file names are starting in the same manner and ending differently which I would like to use to my advantage.
>
>
>
>
>
> I'm guessing fup rename $VOL.SUBVOL.*, $VOL.SUBVOL.NEW* should work. Just that I'm not sure. Yes, I could rather try it, but I'm away at home, considering this be a weekend. Just let me know if this would work? Thank you. :)

Look at greenhouse.de for freeware GROUP (Thanks to the colleages from Miele:)
http://www.greenhouse.de/freeware/guardian-freeware/freeware-details/tools/group.html
With this tool you can do any kind of wildcard operations to grouped files.

wbreidbach

unread,
Jan 27, 2014, 10:31:31 AM1/27/14
to
As far as I know FUP is not able to rename using partial wildcards,
just tried it and FUP returns an error 13:

fup rename testxx??, textyy??
ERROR - $DATA02.WOLFGANG.TESTXX01: RENAME ERR 13
*ABEND*
ABENDED: $X7Z8

Keith Dick

unread,
Jan 27, 2014, 11:39:09 AM1/27/14
to
Rather than creating a macro that just substitutes the last two characters, I thought it was quicker to modify the macro I posted earlier to make it replace suffixes rather than prefixes. I've put that reworked macro below. If you put this in a file named RN2, then this command would do the replacement you asked:

RUN RN2 SS NN

If you want to make it replace the last two characters in the name of every file, without matching the old suffix, you would have to change the two #filenames expressions to just *, with the suffix, and you would not have to compute the length of the old suffix, but could use a constant 2 for that. I think that is all that you would need to change. In that case, you'd probably want to put the macro into a different subvolume than the one containing the files whose names you are changing so that when you run the macro, the [#filenames *] expression does not include the file containing the macro in the set of files the macro works on.

?tacl macro
#frame
[#push fn name newname oldsuffix oldlen newsuffix suffixstart]

[#set oldsuffix %1%]
[#set oldlen [#charcount oldsuffix]]
[#set newsuffix %2%]

[#set fn [#filenames/maximum 1/ *[oldsuffix]]]
[#loop |while| not [#empty [fn]]
|do|
[#set name [#fileinfo/file/ [fn]]]
[#set newname [name]]
[#set suffixstart [#compute [#charcount newname] - [oldlen] + 1]]
[#chardel newname suffixstart for oldlen]
[#charins newname suffixstart [newsuffix]]
rename [name],[newname]
[#set fn [#filenames/maximum 1,previous [fn]/ *[oldsuffix]]]
]
#unframe

Keith Dick

unread,
Jan 27, 2014, 11:49:28 AM1/27/14
to
I forgot to say that, although you are right that TACL programming is enough different from other languages you probably know, once you get to understand the differences, TACL can be pretty easy to use, so don't get discouraged.

Also, although I have not used it myself, the manual titled TACL Programming Guide might be a better manual to use to learn TACL, since that is what it is intended for. The TACL Reference Manual is intended to doument the language completely, without regard to how one should go about learning the language. You certainly will have need of the TACL Reference Manual when writing real programs, especially to find out what built-in functions are available and what they do, but you'll probably learn basic TACL programming faster and easier if you work through the TACL Programming Guide.

Shiva

unread,
Jan 27, 2014, 2:16:54 PM1/27/14
to
@harald: Thanks for your link, though it led me to a file which when I tried to open did give me a "Group" file which had funny symbols but no code. I cannot copy the file and paste it to my computer because I have restricted access at office. So It would be better if I could read the file.

Shiva

unread,
Jan 27, 2014, 2:18:10 PM1/27/14
to
yes, wbreidbach, I even checked what's error 13. It meant that the filename wildcard was not passed properly or something. Forgot the exact words though!

Shiva

unread,
Jan 27, 2014, 2:36:32 PM1/27/14
to
Oh Keith, thanks! Though I don't understand half of that code, I'll spend tomorrow going back to the TACL ref manual to see what each keyword does and means, might also open that Programming guide. It's so fascinating, TACL. Like I mentioned in my first ever post here. And

"If you want to make it replace the last two characters in the name of every file, without matching the old suffix, "..

I think I got you right on that one, you mean to say that the following macro, which I changed as per your instructions should be able to change any file name irrespective of the last two characters into a file with the suffix as we desired.

Like: RUN RN2 $VOLUME.SUBVOL.FILE SS

This should change that filename "FILE" to "FISS". Right? And btw, this following piece of code is my first ever attempt at tacl, even if you are the one who wrote that code. So please don't be harsh on me if I am a bad student, I promise I'll learn. My guess is that I definitely got some of it wrong. Let me know in which places. :)



?tacl macro
#frame
[#push fn name newname * 2 newsuffix suffixstart]

[#set oldlen %2%]
[#set newsuffix %2%]

[#set fn [#filenames/maximum 1/ *]]
[#loop |while| not [#empty [fn]]
|do|
[#set name [#fileinfo/file/ [fn]]]
[#set newname [name]]
[#set suffixstart [#compute [#charcount newname] - [oldlen] + 1]]
[#chardel newname suffixstart for oldlen]
[#charins newname suffixstart [newsuffix]]
rename [name],[newname]
[#set fn [#filenames/maximum 1,previous [fn]/ *]]
]
#unframe

Shiva

unread,
Jan 27, 2014, 2:42:27 PM1/27/14
to
Don't worry, Keith. I'll never give up. Just that, please, you don't give up on me. You're my mentor from far away. When they said there are not enough resources for tandem, I said that it seems like a good challenge. I have lots of questions about tandem, but just taking my time and learning it in parts. So far so good, much thanks to you! I'll buy you lunch one day, for all the help you've given me. :)

And btw yes, first when I started searching about tandem, I also started getting scared that I'd never make it. Because there was no one to guide, no where to read. I did not know that a bundle of manuals exist, from hp. Many people need explanatory books, not manuals. But to me those manuals are bibles. Because I know their value. For someone who thought there was no written documentation of tandem existed, that is an invaluable resource. And when I started glimpsing through it, I understood how well documented most of it is. So it is indeed a piece of cake with the manual around. Just need time.

Keith Dick

unread,
Jan 27, 2014, 3:53:12 PM1/27/14
to
Shiva wrote:
> @harald: Thanks for your link, though it led me to a file which when I tried to open did give me a "Group" file which had funny symbols but no code. I cannot copy the file and paste it to my computer because I have restricted access at office. So It would be better if I could read the file.

Group.zip contains two readme files and group.1729. I believe that group.1729 is a PAK archive. If you can do a binary transfer of it to the NonStop system, then the UNPAK command should be able to extract its contents, but be careful -- PAK and UNPAK are like BACKUP and RESTORE, and unless you put the correct options on UNPAK, it will try to restore the contents to their original volumes and subvolumes. I'll look at the file and tell you a safe command to use in another post, later.

Keith Dick

unread,
Jan 27, 2014, 4:21:27 PM1/27/14
to
There are a few things wrong, as you thought there would be.

Your wording about asking to know about the errors is a little unclear. I'm not sure whether you just want to know where the errors are, or also what the corrections should be. I will only point out where the errors are in this post. If you want to know what the corrections should be, just ask and I will tell you.

I'll put the rest within your text, below what it refers to.

Shiva wrote:
> Oh Keith, thanks! Though I don't understand half of that code, I'll spend tomorrow going back to the TACL ref manual to see what each keyword does and means, might also open that Programming guide. It's so fascinating, TACL. Like I mentioned in my first ever post here. And
>
> "If you want to make it replace the last two characters in the name of every file, without matching the old suffix, "..
>
> I think I got you right on that one, you mean to say that the following macro, which I changed as per your instructions should be able to change any file name irrespective of the last two characters into a file with the suffix as we desired.
>
> Like: RUN RN2 $VOLUME.SUBVOL.FILE SS
>
> This should change that filename "FILE" to "FISS". Right? And btw, this following piece of code is my first ever attempt at tacl, even if you are the one who wrote that code. So please don't be harsh on me if I am a bad student, I promise I'll learn. My guess is that I definitely got some of it wrong. Let me know in which places. :)
>

Not quite. In the macro I wrote, TACL will replace %1% with the first argument and %2% with the second argument. Your changes remove the %1%, so your macro uses only its second argument and doesn't do anything at all with its first argument. So if your changes were working correctly, that command would change the last two characters of the name of every file in the current subvolume to "SS". It would only change the name of $VOLUME.SUBVOL.FILE if your current subvolume when you run that command is $VOLUME.SUBVOL, because it does not look at the first argument -- it just works on all the files in the current subvolume.

Also, since RN2 is in the current subvolume (since you did not qualify its name), one of the files whose name it would try to change is RN2. It would try to make it be RSS. I don't know whether that rename would succeed. I think that depends on whether TACL has the file RN2 open for exclusive use when it is running the macro from the file. TACL might read the whole macro and close the file before starting to execute it. This is why I said that you probably would want to put the macro file into a different subvolume than the subvolume whose files you are trying to rename -- so it would not change the name of itself.

>
>
> ?tacl macro
> #frame
> [#push fn name newname * 2 newsuffix suffixstart]

There is a mistake in the above command.

>
> [#set oldlen %2%]

There is a mistake in the above command.

Keith Dick

unread,
Jan 27, 2014, 5:53:46 PM1/27/14
to
I think harald might not have looked at your original question carefully enough, because after looking at the description of how to use GROUP, I don't see a way to use it to do the kind of renaming you were asking about. Maybe there is something there that I'm not noticing.

I've never seen GROUP before, but my brief explanation of it after my quick look at it is: It provides a way to execute a command on each file in a set of files defined by something similar to a qualified fileset, with some additional capabilities beyond standard qualified filesets. I'm not sure whether GROUP's filesets are a true superset of qualified filesets (I did not check to see whether everything that a qualified fileset can do can be done with GROUP).

Not that there is anything wrong with GROUP, but it doesn't seem to solve the problem you were asking about.

If you still want to look at it, you need to unzip the .zip file you download from the site, transfer the file Group.1729 to the NonStop system in binary mode, then at the TACL prompt enter the command:

UNPAK group,*.*.*,myid,vol $vol.subvol,listall

where $vol.subvol is the volume and subvolume into which you want the files from group placed.
group is the name to which you transferred Group.1729.

If you have a TACLLOCL file, choose $vol.subvol to be different than your logon default volume, because one of the files in Group.1729 is named TACLLOCL, and you probably don't want to replace your TACLLOCL with the one from Group.1729.

The file named ABSTRACT contains some description of how to use GROUP.

wbreidbach

unread,
Jan 28, 2014, 3:30:09 AM1/28/14
to
If you specify the KEEP parameter with UNPAK, no file will be overwritten.

Keith Dick

unread,
Jan 28, 2014, 3:36:19 AM1/28/14
to
That is true, but then you would not get to see the contents of the TACLLOCL file that was in the PAK file.

Shiva

unread,
Jan 28, 2014, 9:31:04 AM1/28/14
to
Hey Keith, sorry that I could not reply to your above posts earlier. I'll reply to them when I get home. I just have a quick query. Remember the tacl program which you wrote, to change the last two characters of a file name? It is above. I compiled it. It gives me error. Saying, expecting |do|. It points to
[#loop
^

Keith Dick

unread,
Jan 28, 2014, 10:42:02 AM1/28/14
to
I'm not sure what the problem is. The user does no compilation of TACL code, so I'm not sure what you mean when you say you got that error when compiling it. Did you really mean you got that error when trying to run it?

I successfully ran the code I posted, unless I slipped up when copying it into the post, so something probably went wrong when you copied it from the post to your system. The |do| for the #loop is on the very next line in the code I posted. Could you have missed that line or mistyped it? Or could you have typed an extra right square bracket on the line that contains #loop? Either of those simple mistakes could lead to the error you got.

If you entered the code on your NonStop system by copy and paste, I have had problems pasting a large group of lines into a block mode program. If you pasted into a TEDIT window, the code might have been garbled a little, maybe causing this problem.

When I want to transfer some text lines to the NonStop system, I either send the file using the "send file" function in the terminal emulator, send the file using ftp, or paste into a line mode interface, such as the original EDIT. You probably don't want to take time to learn EDIT, since you have so many other things to learn. I think you said something about not being able to transfer files to or from the NonStop system. If that is true, then you might have little choice except to paste into a TEDIT window. If so, check the results of your pastes carefully.

Shiva

unread,
Jan 28, 2014, 1:53:13 PM1/28/14
to
Oh, the code worked for you. Okie, I'll double check them again then, first thing tomorrow morning. I wrote an elaborate C language code for that which I had to work out so many problems to make it work. But I made a C equivalent of that tacl code which you made. :) And it worked as well! :D But the code is bigger than what you'd expect. Ha!

Also, I do know the TEDIT interface, being a developer myself, I've to learn to use the TEDIT interface myself and I do know myself about the copy-paste-misfit in the TEDIT interface, since most of my work involves using that editor to write new codes!

And the issue I have about NS is that I work in a high secure environment where I cannot even access the internet, if you know what I mean. So there's no chance of copy paste. I wrote the code down and typed it there myself.

"My guess is that I definitely got some of it wrong. Let me know in which places. :) "

And this line, I definitely meant - Let me know wherever I'm wrong and correct me there too. I wanted to know why I'm wrong. That's why! Because I can learn, right. :D
And why are those two lines wrong? How do I correct them.

Shiva

unread,
Jan 28, 2014, 2:00:42 PM1/28/14
to

> If you still want to look at it, you need to unzip the .zip file you download from the site, transfer the file Group.1729 to the NonStop system in binary mode, then at the TACL prompt enter the command:
>


How does one transfer a file in binary mode? I know about ftp transfers using dos command mode, and also the emulator send / get (or upload / download) option. But I don't know if either of these have a "binary mode" method to transfer a file.

Also what's PAK, UNPAK. You mentioned that it is like BACKUP, RESTORE. Can I compare them with WINZIP for windows? May be PAK, & UNPAK doesn't reduce the size, but they still convert a large number of files into a single file, right? That's the use of PAK?

Shiva

unread,
Jan 28, 2014, 2:07:53 PM1/28/14
to
And Keith, I remember typing the following code inside a file called RN2.

?tacl macro
#frame
[#push fn name newname oldsuffix oldlen newsuffix suffixstart]

[#set oldsuffix %1%]
[#set oldlen [#charcount oldsuffix]]
[#set newsuffix %2%]

[#set fn [#filenames/maximum 1/ *[oldsuffix]]]
[#loop |while| not [#empty [fn]]
|do|
[#set name [#fileinfo/file/ [fn]]]
[#set newname [name]]
[#set suffixstart [#compute [#charcount newname] - [oldlen] + 1]]
[#chardel newname suffixstart for oldlen]
[#charins newname suffixstart [newsuffix]]
rename [name],[newname]
[#set fn [#filenames/maximum 1,previous [fn]/ *[oldsuffix]]]
]
#unframe

And sorry for using the wrong terminology. I did not compile it. But I ran it. Using the same command you mentioned, which is:

RUN RN2 SS NN

And I got an error.
Which mostly pointed said this:

> [#set fn
> [#loop
^
> Expecting |do|

this is what it said, though not exactly. I also saw that the program contained |do| in the next line. But It pointed exactly to the right of loop. Don't know if I'm doing something wrong.

Also, this program is supposed to do the following, right?

> FILES $VOL.SUBVOL.*

$VOL.SUBVOL.*

NAMESS HELLOSS RN2 TACLCSTM NEVERSS

> RUN RN2 SS NN
> FILES $VOL.SUBVOL.*

$VOL.SUBVOL.*

NAMENN HELLONN RN2 TACLCSTM NEVERNN

>

This is what it should have done, right? I'm not sure if I was able to convey it through picture or command line execution notation, but I hope you get it.

Doug Miller

unread,
Jan 28, 2014, 4:22:50 PM1/28/14
to
Shiva <subrama...@gmail.com> wrote in news:ddac3ffb-e254-4d24-a193-
bd4ec7...@googlegroups.com:

> And Keith, I remember typing the following code inside a file called RN2.
>
> ?tacl macro
> #frame

Get rid of the brackets at the beginning and end of this next line. TACL tries to expand
anything that's inside brackets. Even in the minimal case, this wastes processing time at
runtime -- not to mention making your code hard to read -- and in the worst case can lead to
unexpected and unintended side effects.

> [#push fn name newname oldsuffix oldlen newsuffix suffixstart]
>
Get rid of the brackets at the beginning and end of this line too...
> [#set oldsuffix %1%]

and this one...
> [#set oldlen [#charcount oldsuffix]]

and this one...
> [#set newsuffix %2%]
>
and this one...
> [#set fn [#filenames/maximum 1/ *[oldsuffix]]]

For debugging purposes, immediately after that line, insert this, just to make sure that
#FILENAMES is expanding to something:

#OUTPUT First filename found is "[fn]"

Beginning bracket on the next line is required: any construct delimited by vertical bars, such
as |DO| or |WHILE|, is required to be inside a bracketed enclosure.

> [#loop |while| not [#empty [fn]]

When testing a variable, it's simpler to use #EMPTYV instead of #EMPTY:
[#LOOP |WHILE| NOT [#EMPTYV fn]

> |do|

Remove beginning and ending brackets from all of these lines too.
> [#set name [#fileinfo/file/ [fn]]]
> [#set newname [name]]
> [#set suffixstart [#compute [#charcount newname] - [oldlen] + 1]]
> [#chardel newname suffixstart for oldlen]
> [#charins newname suffixstart [newsuffix]]
> rename [name],[newname]
> [#set fn [#filenames/maximum 1,previous [fn]/ *[oldsuffix]]]

Keep this bracket -- it's required to terminate the enclosure beginning [#LOOP ...
>]
> #unframe
>
> And sorry for using the wrong terminology. I did not compile it. But I ran it. Using the same
command you mentioned, which is:
>
> RUN RN2 SS NN
>
> And I got an error.
> Which mostly pointed said this:
>
>> [#set fn
>> [#loop
> ^
>> Expecting |do|

[#LOOP |WHILE| [condition] |DO| ... ] is a perfectly valid construct. You must have mis-typed
something, somewhere.

Given that the error reports *two* lines here, I imagine the problem is actually on the first line
of the two -- most likely you have one more '[' than ']' on that line.
>
> this is what it said, though not exactly. I also saw that the program contained |do| in the next
> line. But It pointed exactly to the right of loop. Don't know if I'm doing something wrong.

Check the code that you're actually running. What you have typed here looks valid, but I
highly doubt that it exactly matches what you are running. I think you will find that one of
these two conditions is the case:
- the #SET command on the line preceding the #LOOP command has one more '[' than ']'
- the first non-space character following [#LOOP is ']' instead of '|'


Keith Dick

unread,
Jan 28, 2014, 5:16:36 PM1/28/14
to
I'm going to have to disagree with Doug about eliminating "unnecessary" square brackets. While there might be some small increase in the amount of processing it takes, my feeling is that is unimportant except in extremely rare cases. The reason for including those "unnecessary" square brackets is that when a variable expands to two or more lines, if the outer square brackets are not there, that will cause an error. Getting in the habit of always enclosing TACL statements in square brackets protects against those cases. So, in fact, whether the outer square brackets are necessary depends on the values of some of the variables, and I think it is much better to be safe and include them all the time.

I haven't looked carefully at all his other comments, but Doug certainly knows TACL, so they probably are correct.

Keith Dick

unread,
Jan 28, 2014, 5:30:40 PM1/28/14
to
If you use Outside View for the terminal emulator, the dialog box that appears when you choose the send command includes a checkbox named "binary". Checking that box makes the transfer copy the data exactly. If that box is not checked, the transfer assumes the file is a text file and will try to convert from the PC's text file format to Edit format on the NonStop system. In ftp the command is "binary".

PAK and UNPAK are similar to Winzip. They are described in the manual Guardian Disk and Tape Utilities Reference Manual. They are clever hacks that start BACKUP or RESTORE and make themselves appear to be a tape drive, while using a disk file for the data instead. However, you said in another post that your environment was highly secure, so maybe you have no way to transfer that Group.1729 file, anyway, unless you can carry files to the PC you use to access the NonStop system on a Flash thumb drive (but that wouldn't be highly secure, would it?).

Keith Dick

unread,
Jan 28, 2014, 5:55:35 PM1/28/14
to
I have worked with some learners who just wanted to know where their errors were, not how to fix them, so they could work out the correction themselves. I didn't want to ruin your fun if you like to work that way, so that is why I asked whether you wanted the correction or just where the error was. Here is your code again, with my corrections:

?tacl macro
#frame
[#push fn name newname * 2 newsuffix suffixstart]
==> I don't know what you intended the "* 2" to do, but I'm pretty sure it won't be accepted by TACL, so you should remove that.
==> Also, "oldlen" should appear in the above list of names. Maybe "oldlen" somehow got changed to "* 2", but that isn't a simple typo.

[#set oldlen %2%]
==> The "%2%" should be just "2". "%2%" stands for the second argument to the macro. You want the value 2.
==> Or you could go through the macro and replace "oldlen" by "2" everywhere it appears.
[#set newsuffix %2%]

[#set fn [#filenames/maximum 1/ *]]
[#loop |while| not [#empty [fn]]
|do|
[#set name [#fileinfo/file/ [fn]]]
[#set newname [name]]
[#set suffixstart [#compute [#charcount newname] - [oldlen] + 1]]
[#chardel newname suffixstart for oldlen]
[#charins newname suffixstart [newsuffix]]
rename [name],[newname]
[#set fn [#filenames/maximum 1,previous [fn]/ *]]
]
#unframe

Those two changes would make the macro work, substituting its second argument for the last two characters of each filename in the current subvolume. You could run it like this:

RUN $VOL.SUBVOL.RN2 x SS

The "x" is there to supply something for the first argument. The way you redid the code, you don't use the first argument any more, but you would have to supply something in the first argument so that the code would see "SS" as the second argument. If you change the "%2%" to "%1%", then you would be using the first argument to the macro as the new suffix, and you could run the macro like this:

RUN $VOL.SUBVOL.RN2 SS

Keith Dick

unread,
Jan 28, 2014, 6:06:57 PM1/28/14
to
Yes, if the macro had run the way it ran for me, it would have renamed the three files whose names ended with SS to make them end with NN. That worked for me when I tested before posting the code.

Shiva

unread,
Jan 28, 2014, 10:17:09 PM1/28/14
to
@Doug: Thanks for the detailed explanation. Will try it out today and get back to you. Probably I made some errors while typing it out. Because I'm new to tacl programming, though this looks like a simple program. :)

Shiva

unread,
Jan 28, 2014, 10:17:59 PM1/28/14
to

> I'm going to have to disagree with Doug about eliminating "unnecessary" square brackets. While there might be some small increase in the amount of processing it takes, my feeling is that is unimportant except in extremely rare cases. The reason for including those "unnecessary" square brackets is that when a variable expands to two or more lines, if the outer square brackets are not there, that will cause an error. Getting in the habit of always enclosing TACL statements in square brackets protects against those cases. So, in fact, whether the outer square brackets are necessary depends on the values of some of the variables, and I think it is much better to be safe and include them all the time.
>
>
>
> I haven't looked carefully at all his other comments, but Doug certainly knows TACL, so they probably are correct.

@Keith: I'll keep that in mind. :)

Shiva

unread,
Jan 28, 2014, 10:21:52 PM1/28/14
to
> If you use Outside View for the terminal emulator, the dialog box that appears when you choose the send command includes a checkbox named "binary". Checking that box makes the transfer copy the data exactly. If that box is not checked, the transfer assumes the file is a text file and will try to convert from the PC's text file format to Edit format on the NonStop system. In ftp the command is "binary".
>

@Keith: I don't use Outside view emulator. Mine's the famous Win6530. A stringent, but a lot more powerful emulator, in my opinion. Though I haven't used many emulators to comment on others.
The ftp command is binary. Hmm, I'll try that on some file. By the way, why do people use that mode while transferring files? So that even the format text remains the same way when transferred?

>
>
> PAK and UNPAK are similar to Winzip. They are described in the manual Guardian Disk and Tape Utilities Reference Manual. They are clever hacks that start BACKUP or RESTORE and make themselves appear to be a tape drive, while using a disk file for the data instead. However, you said in another post that your environment was highly secure, so maybe you have no way to transfer that Group.1729 file, anyway, unless you can carry files to the PC you use to access the NonStop system on a Flash thumb drive (but that wouldn't be highly secure, would it?).

Well, you were right. I can't carry any files to where I work. Even papers with codes which I take in, are only recently allowed. :D

Shiva

unread,
Jan 28, 2014, 10:27:03 PM1/28/14
to
> I have worked with some learners who just wanted to know where their errors were, not how to fix them, so they could work out the correction themselves. I didn't want to ruin your fun if you like to work that way, so that is why I asked whether you wanted the correction or just where the error was. Here is your code again, with my corrections:


I definitely agree with you on that. It is fun to find out our errors ourself. I do that for my other programming skills like say C. Because those languages I know enough to correct my own errors, and it is a challenge I keep to myself to write error free codes even at the first shot. But this case is different for me. I just edited the code to do what I wanted to try. I don't know the language, and definitely not the format. If there's a stage below novice, I could call myself that at this point! That's why I needed your explanation :)


> ?tacl macro
>
> #frame
>
> [#push fn name newname * 2 newsuffix suffixstart]
>
> ==> I don't know what you intended the "* 2" to do, but I'm pretty sure it won't be accepted by TACL, so you should remove that.
>
> ==> Also, "oldlen" should appear in the above list of names. Maybe "oldlen" somehow got changed to "* 2", but that isn't a simple typo.
>
>
>
> [#set oldlen %2%]
>
> ==> The "%2%" should be just "2". "%2%" stands for the second argument to the macro. You want the value 2.
>
> ==> Or you could go through the macro and replace "oldlen" by "2" everywhere it appears.
>
> [#set newsuffix %2%]
>
>
>
> [#set fn [#filenames/maximum 1/ *]]
>
> [#loop |while| not [#empty [fn]]
>
> |do|
>
> [#set name [#fileinfo/file/ [fn]]]
>
> [#set newname [name]]
>
> [#set suffixstart [#compute [#charcount newname] - [oldlen] + 1]]
>
> [#chardel newname suffixstart for oldlen]
>
> [#charins newname suffixstart [newsuffix]]
>
> rename [name],[newname]
>
> [#set fn [#filenames/maximum 1,previous [fn]/ *]]
>
> ]
>
> #unframe
>
>
>
> Those two changes would make the macro work, substituting its second argument for the last two characters of each filename in the current subvolume. You could run it like this:
>
>
>
> RUN $VOL.SUBVOL.RN2 x SS
>
>
>
> The "x" is there to supply something for the first argument. The way you redid the code, you don't use the first argument any more, but you would have to supply something in the first argument so that the code would see "SS" as the second argument. If you change the "%2%" to "%1%", then you would be using the first argument to the macro as the new suffix, and you could run the macro like this:
>
>
>
> RUN $VOL.SUBVOL.RN2 SS

So when I edit it, it will change any file in this sub volume to suffix "SS". Interesting, I might have to compare both this and that code and do some background reading. Thanks for the help, keith! :)

Keith Dick

unread,
Jan 29, 2014, 2:17:20 PM1/29/14
to
Shiva wrote:
>>If you use Outside View for the terminal emulator, the dialog box that appears when you choose the send command includes a checkbox named "binary". Checking that box makes the transfer copy the data exactly. If that box is not checked, the transfer assumes the file is a text file and will try to convert from the PC's text file format to Edit format on the NonStop system. In ftp the command is "binary".
>>
>
>
> @Keith: I don't use Outside view emulator. Mine's the famous Win6530. A stringent, but a lot more powerful emulator, in my opinion. Though I haven't used many emulators to comment on others.
> The ftp command is binary. Hmm, I'll try that on some file. By the way, why do people use that mode while transferring files? So that even the format text remains the same way when transferred?
>
I have only used Outside View, so I don't have any opinion about which is better. And I cannot tell you how to select binary transfer in Win6530. However, I am sure there is some way to do so. I just don't know what it is.

For ftp, at the ftp command prompt, just type the word "binary", and any transfer from then on until you enter the command "ascii" will be a binary transfer.

Ascii transfers modify the file transferred a bit, in the expectation that a file being transferred is a text file native to the source platform, and changing it to be a text file native to the target platform. This usually involves adding or removing carriage return characters, but can be much more. For example, an ascii transfer between an IBM mainframe and a Windows or Unix system would involve a conversion between EBCDIC and ASCII, plus any line termination conversion that would be needed. In the case of a transfer between a PC and the Guardian environment on a NonStop system, the ascii transfer converts between Edit file format (which is not a simple string of characters) and PC text file format.

When the file you are transferring is not a simple text file, but is an executable program, an image file, or anything else that is not just lines of characters, you want the file at the destination to be *identical* to the file at the source. That is what a binary transfer is for.
>
>>
>>PAK and UNPAK are similar to Winzip. They are described in the manual Guardian Disk and Tape Utilities Reference Manual. They are clever hacks that start BACKUP or RESTORE and make themselves appear to be a tape drive, while using a disk file for the data instead. However, you said in another post that your environment was highly secure, so maybe you have no way to transfer that Group.1729 file, anyway, unless you can carry files to the PC you use to access the NonStop system on a Flash thumb drive (but that wouldn't be highly secure, would it?).
>
>
> Well, you were right. I can't carry any files to where I work. Even papers with codes which I take in, are only recently allowed. :D

That will make it hard for you to post examples of problems you are having or to use any example code or useful utilities sent to you. I'm sorry you have to work under such restrictions. I hope the restrictions really are necessary, not just due to crazy management.

Keith Dick

unread,
Jan 29, 2014, 2:52:10 PM1/29/14
to
Shiva wrote:
>>I have worked with some learners who just wanted to know where their errors were, not how to fix them, so they could work out the correction themselves. I didn't want to ruin your fun if you like to work that way, so that is why I asked whether you wanted the correction or just where the error was. Here is your code again, with my corrections:
>
>
>
> I definitely agree with you on that. It is fun to find out our errors ourself. I do that for my other programming skills like say C. Because those languages I know enough to correct my own errors, and it is a challenge I keep to myself to write error free codes even at the first shot. But this case is different for me. I just edited the code to do what I wanted to try. I don't know the language, and definitely not the format. If there's a stage below novice, I could call myself that at this point! That's why I needed your explanation :)
>
Okay. From now on, I'll remember that when you show me some code that is wrong, I will tell you how to correct it. If you later decide you want just to know where an error is, so you can try to figure out the correction yourself, be sure to tell me to just point to the error.
Yes, that is what it will do. That is because the #filenames expression is just "*", so it will select every file in the current subvolume. The other macros were written with #filenames expression of [prefix]* or *[suffix], so they select only the files whose names begin with the prefix given or only the files whose names end with the suffix given.

It does not have to be like that. If we devised some other way for the loop to get the set of file names to work on, we could make it change the names of only those files.

You could add tests within the loop to check for file names that you never want it to change, and only do the rename if the current file is not one of the ones you want it to leave alone. There are at least two ways I can think of to do that. Another approach would be to make it prompt the user with the filename and wait for a yes or no answer to tell whether that file should be renamed. There are lots of possible ways to make it work other than renaming every file in the current subvolume.

wbreidbach

unread,
Jan 30, 2014, 2:25:50 AM1/30/14
to
Doing binary transfer with WIN6530 is pretty easy:
click on FILE -> Transfer and you will get a menu for transferring a file including binary. Unfortunately this transfer is very slow. FTP is much, much faster.

Randall

unread,
Jan 30, 2014, 10:42:04 AM1/30/14
to
Still going to suggest using JSch and SFTP to do this from Java. The API is really simple to use and you can do both Guardian and OSS files securely. Nothing should go in the clear in most environments anyway.

Shiva

unread,
Jan 30, 2014, 1:46:47 PM1/30/14
to
> I have only used Outside View, so I don't have any opinion about which is better. And I cannot tell you how to select binary transfer in Win6530. However, I am sure there is some way to do so. I just don't know what it is.

I found a way to transfer using Win6530 with binary on, in the emulator itself. Wasn't even half as hard. :)

> When the file you are transferring is not a simple text file, but is an executable program, an image file, or anything else that is not just lines of characters, you want the file at the destination to be *identical* to the file at the source. That is what a binary transfer is for.

Got you on that one, keith. I guessed pretty much already, but that explanation was detailed. Cool! :)

> That will make it hard for you to post examples of problems you are having or to use any example code or useful utilities sent to you. I'm sorry you have to work under such restrictions. I hope the restrictions really are necessary, not just due to crazy management.

Not crazy management, keith. Really necessary. :) But I like the challenges. The harder it is to learn, the more interesting it is, for me. :D

Shiva

unread,
Jan 30, 2014, 1:48:29 PM1/30/14
to
Sure, keith. That seems interesting. I should take this up as a task. If I start creating macros such as this using tandem, hoping to reduce my workload against the system, I might even learn a lot of tacl during the process.

Shiva

unread,
Jan 30, 2014, 1:51:57 PM1/30/14
to
@wbreidbach: Yeah, I experienced it. And to you and to @Keith, I have another question. I'm working on both G & J series tandem machines for the moment. And the J series machine keeps blocking me from ftp usage on DOS. Probably a admin setup. It says SSL active. What would that mean? asks me to use sftp I guess. And the credentials for it, are pretty different.

Shiva

unread,
Jan 30, 2014, 1:53:49 PM1/30/14
to
@Randall Hey Randall, what's JSch? And sftp - I encountered this while trying ftp on windows command prompt. What do you mean, "do this from java?" And before you ask me to download any application or anything, let me tell you I do not have access to the internet in the environment I work in.

Keith Dick

unread,
Jan 30, 2014, 4:18:28 PM1/30/14
to
Shiva wrote:
> @Randall Hey Randall, what's JSch? And sftp - I encountered this while trying ftp on windows command prompt. What do you mean, "do this from java?" And before you ask me to download any application or anything, let me tell you I do not have access to the internet in the environment I work in.

It seems Randall thinks you wanted to do a file transfer from within a program, not as an interactive user. At least that is how I interpret what he wrote.

Keith Dick

unread,
Jan 30, 2014, 4:22:55 PM1/30/14
to
Shiva wrote:
> @wbreidbach: Yeah, I experienced it. And to you and to @Keith, I have another question. I'm working on both G & J series tandem machines for the moment. And the J series machine keeps blocking me from ftp usage on DOS. Probably a admin setup. It says SSL active. What would that mean? asks me to use sftp I guess. And the credentials for it, are pretty different.

I don't know what that message means. Maybe Wolfgang or someone else knows and can explain. But your guess that it is a configuration choice by the system administrator seems a likely explanation. If you have a need to do file transfers for your work, it would be reasonable to ask whether some form of ftp could be made available. It is faster.

Randall

unread,
Jan 30, 2014, 7:17:18 PM1/30/14
to
This is a true interpretation. But writing an interactive program in Java from a workstation or from NonStop is not actually hard (read "easy"), and usually worth the investment in this case. With that said:

SFTP is SecureFTP. SFTP comes with NonStop SSH, which you should be able to get installed. It also available on Windows and native on virtually all Linux incarnations. SSH - Good. Not SSH - Bad (your file transfers are visible in plain text). It is the server-side.

JSch is a Java library that implements SSH in Java. It has a very simple API. I have used it to upload/download EDIT, Objects, OSS files in text and binary. It is the client side.

The advantage: You can present whatever interface you want. Am I a fan? Absolutely. Could I do cool stuff without it? Uh... I could, but wouldn't like it.

wbreidbach

unread,
Jan 31, 2014, 2:38:02 AM1/31/14
to
On S-Series, SFTP was available from some 3rd parties and you had to pay for it. On the new systems, SFTP (in fact SSH) is included.
I suspect, that you administrator has disabled FTP. In that case you would not be able to connect to the system using FTP. If you can connect and you are not able to login I remember another issue: If you are using an alias as a user and that alias contains lowercase letters, some versions of FTP will convert those lowercase letters to uppercase before verifying user and password and the verification will fail. This has been fixed some time ago.
SFTP is working similar to FTP but usually you do not have sftp installed on your PC.

Shiva

unread,
Jan 31, 2014, 4:37:46 PM1/31/14
to
@Keith: That's fine, thank you keith.

@Randall: I've no knowledge about JSch, and from what you've said I guess it would be worth the look.

@Wbreidbach: I'm sure that my admin has disabled FTP. Not using an alias. I don't think I'd need any sftp installed on the PC. I just typed sftp on the command prompt, just that it took me to a screen where I didn't know what to do. It sure as hell asked me some credentials which I doubt I had. I'll post the reply what my admin gave, on monday night lads. :D

Randall

unread,
Feb 1, 2014, 10:33:35 PM2/1/14
to
If you received a reasonable response from a SFTP, you probably have NonStop SSH installed. It is asking for a valid user ID that can log on to OSS. If you have a keypair installed (Google .ssh keypair keygen) it will likely process it too. Many companies are progressively disabling FTP because it is no longer acceptable by policy and SFTP is reasonably well encrypted. WinSCP is a decent Windows client. The FileZilla works on MAC as an SFTP (allegedly, but I haven't tested it with NonStop SSH).

dave....@gmail.com

unread,
Feb 2, 2014, 6:36:37 AM2/2/14
to
I don't mean to be a prude, but I am a little put off that so much advice is being offered to help someone defeat what are probably legitimate security defenses in place at his or her workplace.

Shiva

unread,
Feb 2, 2014, 2:30:25 PM2/2/14
to
On Sunday, 2 February 2014 17:06:37 UTC+5:30, dave....@gmail.com wrote:
> I don't mean to be a prude, but I am a little put off that so much advice is being offered to help someone defeat what are probably legitimate security defenses in place at his or her workplace.

Hey dave, I don't mean to be prude either. But seriously, "help someone defeat security defenses at one's workplace"? I request you to go through this whole series of posts for once. Because neither did I ask advice to defeat the security defenses at my workplace, nor did I request help to overrun/bypass or - whatsoever word you might add there - my workplace's security. Because obviously, like I mentioned above, my workplace is secure for a reason and I love the challenge, like I mentioned above.

Also, to be more clear, my problem was that I was unaware of all these security defenses and I was actually requesting for more information on how to use these security firewalls, not as in how to break them. Thank you. :)

Shiva

unread,
Feb 2, 2014, 2:32:07 PM2/2/14
to
@Randall: I get that point. I guessed pretty much, as well. But my issue is that the user ID which I use for ftp is not working with sftp. My guess is that the credentials here are different, and my admin is the best person to ask, about this. Thanks for all your help though! :)

Shiva

unread,
Feb 3, 2014, 9:03:00 AM2/3/14
to
@Keith: It was a matter of spaces. I cleared it, and it worked like a charm. Thanks again :)
0 new messages