Script to automate a service message

Hi

I am trying to figure out, on how to automate whether in a simple script or using awk/sed/grep commands to automate a "service.message" file which has tag separated message stating as;

"There is currently no outage or system is unavailable for duration of change....", therefore, when users log into the application front end they will see this message and phone number/email etc and they click on dismiss or continue to progress. Image attached.

I am only interested in the service message portion, to include few lines, nothing else...How can this be achieved using any regular expression commands or simple script?

Thanks.
G:b:

What operating system and version are you using?

Search this forum and the web for '/etc/motd' (which stands for "message of the day").

Do you want users to see your message when they login to the system or when they launch a particular application?

Hi

I am using Linux version 7.2 and I want users to see the message when they log into the application via front end i.e. url. And here they will see the message and click on dismiss continue etc... This could be when we are delivering a new release, every quarter and so on.

At the moment it is just manual process, and just needs the message portion, few lines automating, within a .sh script probably will do the trick.

Hope this helps. Please Advise.
Gaz

---------- Post updated at 12:42 PM ---------- Previous update was at 09:46 AM ----------

The other thing is /etc/motd probably works as if you are logging into a shell rather than displaying this message on front end application, so been searching around, don't think that will be helpful?

I don't know if there is something sed command or simpler which can replace or setup custom tags between the service message?

Let me know your thoughts.
Thanks

So users connect to the application via a URL so shouldn't this be coded in html rather than a Unix shell?

Yes, it could be in html as currently the file which has that service message line "xxxxx" is in html. Therefore, I thought there could be something using some file manipulation commands to read from another file to achieve this though...maybe not....

Any idea's?
Thanks

What is your application? What language is it written in? It'd make more sense to do so in the application.

Hi

Its an application used for criminal justice system running on backend WebSphere/Linux and DB2.

You cant do it from the app, otherwise it would have been done but its been done manually by editing the service.message file but we just want this portion updated...whether its a one liner, realistically speaking not really required to invest time and effort but business want this automated so the transition team then can support the app and run the automation in future.

I was looking at SED, today, maybe there is some way to set this up...
Hope this Helps.

Thanks

I would generate the file completely rather than editing it. Replace it each time, rather than trying a brute-force regex and hoping the different text won't mess it up each time. Much more reliable.

( cat header-file
echo "part of text that varies"
cat footer-file ) > /path/to/outputfile

Without seeing the file you want edited we really can't help you much further. And I suppose you can't post it.

Hi

Yes, its pretty small file but Yes, it would be difficult to But what I have done is replaced with dummy text where it occurs and shown below:

The only bit that needs changing and automating is the highlighted in RED below: Hope this Helps.

 <p><strong>Welcome to  ABC </strong><p>
<p>ALL TEXT HERE.... </p>
 <p>ALL TEXT HERE. </p>
 <hr>
<p>Text Here</p>
<p> Details <br> Email: <a href="EMAIL">EMAIL ADD </a></p
>
 <p>Hours of Service: 24x7 for Priority  incidents, 07:00 to 17:00 Mon to Fri (excluding public holidays) for all other priorities
s.</p>
<hr>
<p><strong>Service Message</strong></p>   (HERE Text needs to be added)
<p>There are currently no outages planned </p>
<br>
<hr>

Thanks

#!/bin/sh

cat > /path/to/outputfile <<EOF
 <p><strong>Welcome to  ABC </strong><p>
<p>ALL TEXT HERE.... </p>
 <p>ALL TEXT HERE. </p>
 <hr>
<p>Text Here</p>
<p> Details <br> Email: <a href="EMAIL">EMAIL ADD </a></p>
 <p>Hours of Service: 24x7 for Priority  incidents, 07:00 to 17:00 Mon to Fri (excluding public holidays) for all other priorities
s.</p>
<hr>
<p><strong>$1</strong></p>
<p>There are currently no outages planned</p>
<br>
<hr>
EOF

Use it like ./script.sh "Service Message" to regenerate the file.

Hi

I will give that a go tomorrow after I have added the text and what type of service message to be added and will see how it works.

I don't need to amend anything else or pass any parameters?

./script "service message" to run the script

Let you know.
Thanks.

No matter what you do, keep a backup of the original message file.

If the actual file is different from what you showed you'll need to change it, of course.

The script will need to be set executable to run, also.

chmod +x ./script

Hi

Yes, will take a backup of the original service.message file and then try this code and see if it works....

  • I can add few lines of text, where service message is there is no min/max char values to input text between the below lines of code?
  • <p>There are currently no outages planned</p>
    <br>
  • You mentioned path of output file: /data/profiles/content/(filename) and will make the script executable of course.
  • That's ALL the file contains as I have shown you ONLY text I changed.

Thanks.

Hi

Thanks, I have tested the script and it works as expected showing the edited message.

However, I we don't want users(Transition Team) to be modifying the script's so incase something else mess ups. Therefore,

Can we call 2 files with the script as follows

file 1-service_template (which will have all the welcome board message, numbers/emails etc)

file 2-service_message.txt ( This will have a paragraph of message in this file...)

file 3-Will be our initial script which when run calls these two and updates, so no one actually modifies the script, rather than the ONLY service_message.txt file which will have the outage message few lines.

How can I achieve this, as I have created the first 2 files and the script portion is which needs more addition or amendment?

Thanks

They never had to modify the script to modify the message in the first place, so I'm not sure what your point or question is.