cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to search for a string in an ACL file?

MB_8500855
Participant

Is there a way to search for a string in an ACL file?

I have looked for an answer in the various posts but have not found anything, so here is the question.

I am using Arbortext Editor 5.3. We have a couple of script files (init.acl and user.acl) on a network folder, say s:\scripts.

To avoid network latency the script files are copied to a local hard drive and loaded from there when Arbortext is executed. Occasionally one or more of these scripts may change. I want to make it easy for users to check for updates by providing an menu option they can use.  The idea is it checks the version of the local script and then checks the version of the network script.

 

In each script file I put a version that I want to check against later, e.g $initscriptver=1 and $userscriptver=1, 

what I want to do in my check_for_updates.acl script is something similar to the following:

  1. Open the network script file (e.g. s:\scripts\init.acl)
  2. Find the line containing the version number (e.g. $initscriptver=1)
  3. Extract the version number from the line
  4. Compare the version number I extracted with the one in the loaded script

I am having trouble working out how to do step 3 (and possibly step 2 ). As I may not be the only one updating the scripts, the  version number position may change (e.g. there could be whitespace either side of the "=")

 

An example of the code is:

 

 

function Find_string_in_file(strtofind, from)
{
	srcFile = open(from, "r")
	if (srcFile < 0) 
	{
		eval "Couldn’t open file for read:", from
		return 0 
	}
	while (getline(srcFile, line)) 
	{
		$pos=span($line, $strtofind);
		if ($pos > 0)
		{
			#
			# extract the version somehow
			#
			break;
		}
	}
	close(srcFile)
	return 1; # True
}

 

 

Any pointers would be greatly appreciated.

Tags (1)
5 REPLIES 5

Re: Is there a way to search for a string in an ACL file?

You can do it this way but I would recommend to save yourself the hard work and use the built-in Arbortext feature
"zipped customisations". This is documented in the Arbortext Help Center (topic #17122). In your case you can host your custom scripts on a web server and on the client simply set APTCUSTOM=http://my.server.com/arbortext/scripts.zip

Here is an extract:

You can deploy not only custom directories, but also application and content management system adapters directories in a compressed zip file. Using a zip file to distribute your customizations has the following advantages:
  • You can host your customizations on a web server.
    In this case, use the HTTP or HTTPS URL to the zip file as the value for the APTCUSTOM environment variable.
  • Your customizations will be available to users when they cannot access your network.
    If you use a shared network folder to host your customizations, users do not have access to those customizations when the network is unavailable. If you use a zip file to distribute your customizations, Arbortext Editor unzips those customizations to a directory in the Arbortext Editor cache directory (.aptcache\zc). At start up, Arbortext Editor checks to see whether the zip file has been updated. If it has, Arbortext Editor downloads and uncompresses the updated customizations. If not, Arbortext Editor continues to use the customizations stored in the local cache. If the network is unavailable to a user, your customizations are still available to that user in the local cache. Note that the user must also have a fixed Arbortext Editor license on their system to work away from the network.
  • Network traffic might be reduced.
    Since the zip file containing your customizations is only downloaded once over the network, and then only if it has been updated, traffic on your network might be reduced. If you store your unzipped customizations in a shared network folder, Arbortext Editor might have to access that folder several times over the course of a session.
  • Customizations stored in a compressed zip file are harder to change accidentally than customizations stored in a directory structure.

Re: Is there a way to search for a string in an ACL file?

Thanks for your reply, Gareth. I would love to make my jo simpler but, alas, the organisation I work for has pretty much locked everything down on the local drives and also wrt web servers. I am in a technical publications team and the scripts are for the team. They do not have a wider audience so even if we were able to deploy a webserver it would probably be overkill. We are very much restricted to what we can access on a network drive and essentially one unlocked folder on our local hard drives. So I am somewhat forced to do it the hard way.

Cheers

Re: Is there a way to search for a string in an ACL file?

I think the zipped customisations can work from a regular file share too, as you don't have a web server. Try it out and see? This will avoid you needing to write any code.

Re: Is there a way to search for a string in an ACL file?

I'm not able to use customizations. Is there a way to get a string from a text (script) file?

 

Thanks

Re: Is there a way to search for a string in an ACL file?

The Arbortext Help Center is a great resource. It is included with Arbortext as an optional download and is also available online: https://support.ptc.com/help/arbortext/r8.1.0.0/en/

Navigate to Programming -> Arbortext Command Language -> Functions by Category -> File Identifier Functions. You will find complete reference materials for open() read() seek() getline() close() etc.

Announcements