Action script assistance required

I have 1000 clients ( mix of windows / AIX / Linux / Solaris ) .

My Requirement :

I have one config file name called ClientAgent.cfg .It’s available on all OS . But file location is different on all OS ( windows/AIX/Linux/Solaris)

I need find the file “ClientAgent.cfg” first & comment 2 lines inside the file & append 2 new lines for all the servers .

I need action script . Is that possible ?

I can do windows as one action & all Unix as another action also .

Please help me .

One quick example

cat ClientAgent.cfg

rest.protocol=http
rest.port=1082

These 2 lines has to be commented & add below entries as example .

cat ClientAgent.cfg

#rest.protocol=http
#rest.port=1082
rest.protocol=https
rest.port=8082

Hi @goperiya1,

This action script should provide you a starting point (if we imagine the file is in c:\):

delete __appendfile
appendfile { concatenation "%0D%0A" of (if it starts with "rest.protocol" then "#" & it else if it starts with "rest.port" then "#" & it else it) of lines of file "c:\ClientAgent.cfg" }
appendfile rest.protocol=https
appendfile rest.port=8082
delete "c:\ClientAgent.bak"
move "c:\ClientAgent.cfg" "c:\ClientAgent.bak"
move __appendfile "c:\ClientAgent.cfg

Line 2 is where the old port and protocol lines get commented out.

You can make it a fixlet by using something like this for the relevance:

exists file "c:\ClientAgent.cfg" whose (not exists line whose (it = "rest.protocol=https") of it or not exists line whose (it = "rest.port=8082") of it)

The *NIX version would be roughly the same but you’d change “%0D%0A” to “%0A” on line 2 to allow for the newline difference.

I have no HP-UX experience but where I’ve needed to create properties that cater for Windows / Linux / Mac OS and I try to use a standard approach to cater for supporting a mixture of OS’s within a single fixlet/property.

Firstly I would list out what paths you have for each OS then build a relevance statement that covers the pathname for each OS. For Windows, Linux / Mac I use this as a guideline

((if (windows of it) then (folder "WidowsPathHere") else (if(unix of it) then (If(name of it as lowercase contains "linux") then (folder "LinuxPathHere") else (folder "UnixPathHere")) else (if(mac of it) then ("MacPathHere") else (nothing)))) of operating system)

Then, build relevance to parse the file based on its format (assuming the format is common across the various OS). An example of parsing a common formed text file across OS like this can be seen in Universal append to hosts file which may help you construct something for your specific use case.

Thanks a lot. I will test it today.

Hi Team,

I have one more doubt here. in the ClientAgent.cfg file, if I want to add one line as SITE_CONTROLLER_ADDRESS=192.x.x.x

kindly note: I want to check one condition like whether we any line entry present SITE_CONTROLLER_ADDRESS=
( without any IP address assigned ) and add my new IP address .

kindly help me in this request .

As example:

cat ClientAgent.cfg

rest.protocol=https
rest.port=8082
SITE_CONTROLLER_ADDRESS=192.x.x.x