Sunday, September 25, 2022

Notification from RPA by LINE

Notification from RPA by LINE

My Cloud Computer has recently become an RPA dedicated execution machine called Sikulix, and it runs more comfortably and crisply than my home computer (my personal opinion). After all, it is physically located in a data center, which is (probably) closer network-wise to the target access server, and best of all, it is not affected by the congestion and failures of service providers. Even I don't do stock or crypto assetes at all, but I imagine that the popularity of cloud use among those people is partly because they are playing a more serious game in this area.
I used to use Gmail to notify when RPA was being executed or finished, but I decided that nowadays it is not necessary to use e-mail, so I decided to use LINE, which is popular mainly in Japan and some other Asian countries.
Although we use LINE casually, various APIs are available to application developers. In this case, I just want to send a message, so I'll use LINE Notify to make it as easy as possible. From the LINE Notify page, create a token, which is very popular nowadays. Token is a new word, but it is not so wrong to think of it as just a long password. Copy and paste this into a file on your Cloud Computer and save it. After that, all you have to do is access the dedicated LINE Notify page with your message. It's that easy. You can also send the message by typing in the URL in your browser, but it would be better to use a script since it would take a lot of time. In this example, we put the following contents in the file sendline.sh, and then type

#! /bin/bash -f
curl -X POST -H 'Authorization: Bearer '`cat linetoken` -F 'message="'$1'"'' https://notify-api.line.me/api/notify
#! /bin/bash -f
curl -X POST -H 'Authorization: Bearer '`cat linetoken` -F 'message="'$1'"'' https://notify-api.line.me/api/notify

Add execution rights.

$ chmod +x sendline.sh
$ chmod +x sendline.sh

Note that in the above example, the tokens are stored in a file called linetoken. The cat linetoken` is a symbol to tell you to extract the contents of the file linetoken on the command line. The $1 means to set the value written at the back (called argument) when executing. When you run the command, it looks like this.

$ . /sendline.sh "line message from Cloud PC"
$ . /sendline.sh "line message from Cloud PC"

It seems that the destination of the line is not written, but that information is contained in the token issued. I wrote above that it is just a long password, but the token seems to have a slightly different role. Sikulix, which is an RPA tool, uses python, so when you call it from there, it looks like this

# Send a message from Sikulix Python to LINE
m = "Message from Sikulix"
subprocess.call(['linesend.sh', m])
```

As a result, I received a message from **LINE Notify** without any problems (:-). This could be used in many ways.
# Send a message from Sikulix Python to LINE
m = "Message from Sikulix"
subprocess.call(['linesend.sh', m])
```

As a result, I received a message from **LINE Notify** without any problems (:-). This could be used in many ways.

Labels: , , ,

Sunday, September 18, 2022

Notification from RPA by GMail

971 Notification from RPA #1 GMail
Notification from RPA #1 GMail

I have Sikullix in my Cloud Computer and I am playing with RPA and other things, but I can't watch it all the time after it starts because I let it run for a good long time, but I don't know when it finishes or it may have ended up with an error for some reason in the middle of the process. So, even very simple idea, but I'm going to use Gmail to notify me when the process is finished or when there is an error.
Of course, since I am dealing with RPA so far, we could use that to send it via webmail from a browser, but it would be a lot of work to start a browser, access the Gmail page, go to .... and as anyone who has ever made RPA knows, it doesn't work quite as well as I'd like (;-s). Especially this time, I want to send an email even when an error occurs while letting the user surf the web using a browser, but it is not a good idea to send an email through the browser because the error may be caused by the browser. Also, since I am a command line lover (:-), I will make this part with a script. However, my current theme is a Cloud Computer, so I don't mean to make it a mail server. It is just a normal Computer that can be used to send mail.
In the case of Ubuntu, it is under /etc/postfix. However, since security is getting stricter these days, you need to issue an application password on the Gmail side and set it up on your cloud computer as well.

On the Gmail side, go to AccountSecurityApplication Password.

Write this password in a file named sasl_passwd, excluding spaces. When ready, create transport.db and sasl_passwd.db and restart postfix. It looks like this.

$ sudo postmap /etc/postfix/transport
$ sudo postmap /etc/postfix/sasl_passwd
$ sudo systemctl restart postfix
$ sudo postmap /etc/postfix/transport
$ sudo postmap /etc/postfix/sasl_passwd
$ sudo systemctl restart postfix

Now all you have to do is send mail as usual.

$ echo "body of mail" | mail -s "subject of mail" mail to (xxxxx@xxx.com)
$ echo "body of mail" | mail -s "subject of mail" mail to (xxxxx@xxx.com)

The command line world is easier to understand than RPA after all (:-), and there are many cases where it is better to use scripts to do things that can be done with RPA. If you try to do everything with RPA, you will see a tough world a bit (:-).

Labels: , , , ,

Sunday, September 11, 2022

Markdown Editor

I have just started using a markdown editor, which is very popular these days. In the old days, I used to write directly html tags and such in an editor (:-u), but that is not very efficient these days, so I think markdown editors are very good tools that allow various modifications to be made with text.
Recently, so-called integrated environments for coding, not just markdown, seem to be very popular. Some of them can do various things, not only check the syntax of a programming language, but also compile, run, and debug it. This may be due in part to the increase in the number of people coding with the spread of python. Many people, especially science students, may have used python at least once. I think markdown is also ideal for writing papers that include mathematical formulas.
I have also tried several tools such as Boostnote / Atom / VS-Code / Inkdrop, and tried programming Sikulix, an RPA tool, and writing this blog, each full of great features and very interesting, but in the end I reverted to vi for coding (lol). I guess it's hard to change the habits you acquired in the past, and there is still nothing that can beat the ease of operation of moving the cursor without taking your hands off the keyboard (without a mouse), or the regular expression + line search and replace (just my personal opinion, lol).
I went back to vi for coding, but for blogs and memos, I want to use a markdown editor because I use Japanese , two bytes charactors, and I don't want to use the Japanese input in vi because the ESC and Kanji keys are so close together that I often press the wrong keys. So, let me summarize my requirements for a markdown editor

  • Convert to html
  • Can be used and shared on multiple devices
  • Free of charge (lol)

There are some blogs these days that can upload markdown as-is, but I may switch to a new one in the future, so html uploads are more stable. If possible, it would save me time if I could copy it to the clipboard instead of outputting it to a file.
Also, since I want to write blogs whenever I have an idea, I would like something that can be used on PCs (Linux/Windows), tablets, and smartphones (iOS/Android) and that allows me to share what I have written.
I would be happy to pay for a tool if I really need it, but since I have gone back to using vi for programming, I don't need complicated functions, so I think a free tool would be sufficient.
I started with StackEdit, which meets these requirements, and it is quite good: it can be easily shared using Google Drive, and since it is http-based, there are almost no restrictions on devices or operating systems. Best of all, the html output can be easily exported to the clipboard. However, for some reason, I can't copy and paste on iOS, which I think is the case at this point. For some reason nothing is in the clipboard when I copy. It is possible that my settings are bad, but not being able to copy and paste is fatal for an editing tool.
After that, I tried Joplin and have been using it up to now. html conversion is a little disappointing that it only outputs files and not copy to clipboard, but other than that it is very comfortable. Even I may switch to another app soon. (LOL.

Labels: , , ,

Sunday, September 4, 2022

RPA on Cloud Computer #2

I started using Cloud Computer, a local but NTT-affiliated service in Japan, with 2 CPUs and 2 gigabytes of memory for a reasonable (I think) maximum of 700 yen/month. The Dynabook N40 at home has taken on a second life (lol) as a Thin Client.
There is one thing I would like to confirm before using RPA with Cloud Computer this time. What is the resolution of the screen when not connected to Cloud Computer via VNC? ** I don't know what you are talking about. I know you don't know what I'm talking about, but I don't know much either (lol)... When I was still an active engineer about 20 years ago, most of my work and geeky activities were done on the command line. Of course, I used X-Window and Windows, but I used them only as it is, with no customization. So I am not good at this area at all. By the way, command line is what is called CUI or shell, and it is the world of computers without using a mouse. For some person, it is more understandable, let's say , it is just like MS-DOS.
RPA is a part of the mouse-using culture. In a world without a mouse, there are only commands, so there is no need to bring in the concept of RPA, and all you have to do is to write a list of commands and execute them in order from the top (with some logic, of course). Before the advent of RPA, I remember that even when surfing the Internet, I had to acquire information from scripts and programs via http and then analyze the tags. However, with the development of CSS and other technologies in addition to images and videos, information processing by tag analysis is complicated and difficult, so it has become simpler and quicker to automate the world as it is, which is what RPA is. I think this is what RPA is all about.
In RPA, of course, if the resolution changes, the images of buttons and input fields may not match the images prepared in advance, so it is necessary to know the resolution. Therefore, it is necessary to know the resolution of the screen. However, while RPA is being executed on a cloud Computer, it is left unconnected from the home PC, so the screen is not physically output anywhere during that time. However, the RPA is working by properly understanding the location and contents of the Window of the application, which is not visible to humans. What is the screen resolution at that time? is my question.
At the result , I understand that, when the RPA is running on a Cloud Computer, the monitor is connected even if the screen is not physically output anywhere. When I ran it with no VNC connection and only an ssh connection, I got the following message

$ xrandr
Screen 0: minimum 32 x 32, current 1920 x 1200, maximum 32768 x 32768
VNC-0 connected primary 1920x1200+0+0 0mm x 0mm
$ xrandr
Screen 0: minimum 32 x 32, current 1920 x 1200, maximum 32768 x 32768
VNC-0 connected primary 1920x1200+0+0 0mm x 0mm

On the Cloud Computer side, the VNC application (vncserver) is launched, so it is the monitor. In other words, when the vncserver was started, the monitor was already connected from the OS point of view, and whether or not the VNC app was viewing it from the home computer was not important to either the OS or the RPA. So if you want to run RPA from your home PC on a Cloud Computer, you don't necessarily need to connect via VNC, just an ssh connection.

$ xrandr --output VNC-0 mode=1920x1080
java sikulix ...
$ xrandr --output VNC-0 mode=1920x1080
java sikulix ...

I found no problem if I specify the resolution first and then run the program. To be honest, it was getting a little hard to start up an application for mouse (so-called desktop) on my Dynabook N40, which is my home thin client, but now that I know I can run RPA from just the command line, I'll let it work a little longer (lol).

Labels: , , ,