Saturday, August 10, 2024

Configure Rsync - Transferring and synchronizing files between two machines in same network

 


Configure Rsync in Oracle_Enterprise_Linux6.8


 Rsync is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive and across networked computers by comparing the modification times and sizes of files.

Transferring and synchronizing files between two machines in same network.

  1. Let suppose we have two servers DB_SRV -192.168.32.128 and APP_SRV -192.168.32.131


  1. Objective - Transferring and synchronizing a directory or files from APP-SRV to DB_SRV.


  1. It will ask for user password while transferring or synchronizing from one to another server and with different user i.e. (root-oracle, oracle-weblogic, and weblogic-root).


  1. But if we want to transfer files without entering the password we will have to configure SSH key pair and sshpass utility on both servers.  


BASIC SYNTAX FOR RSYNC

Rsync [‘options’] [‘source-directory’] [‘@Target Host:/Target-directory’]

  • Options used for rsync(common options only)

-v, –verbose               Verbose output

-q, –quiet                   suppress message output

-a, –archive                archive mode allows copying files recursively and it also preserves symbolic links, file

-r, –recursive             sync files and directories recursively

-b, –backup                take the backup during synchronization

-u, –update                 don’t copy the files from source to destination if destination files are newer

-l, –links                     copy symlinks as symlinks during the sync

-n, –dry-run                perform a trial run without synchronization

-e, –rsh=COMMAND mention the remote shell to use in rsync

-z, –compress             compress file data during the transfer

-h, –human-readable display the output numbers in a human-readable format

–progress                   show the sync progress during transfer

-d: indicates               change in destination file

-f: indicates               a file

-t: indicates               change in timestamps

-s: indicates               change in size

Syntax example - (rsync -a /u01/Rsync_Test/*.pdf @192.168.32.128: /u01/Rsync_Test/)











STEP1- TO CONFIGURE RSYNC IN OLE6.8

  • Login server using root user /or/ Switch user to root.



  • To install rsync type –

  • Go to Packages directory it will mostly found in /media

 Type below command


rpm -ivh rsync-3.0.6-12.el6.x86_64.rpm then Press Enter.








  • Then type  below command and press enter to install required package for rsync

  • Yum install rsync*

     


Step2- Create Directory and Give Permission on Both Servers.

  • So As per Requirements we have to transfer files inside Rsync_Test of App-Server to DB-server.

  • Check files inside Rsync_Test directory of application server and database server.

DB-SERVER (192.168.32.128)




APPLICATION-SERVER (192.168.32.131)


Step3- Type below command to transfer the files from one to another server.

  • Run below command on app-server (192.168.32.131)

rsync -a /u01/Rsync_Test/*.pdf oracle@192.168.32.128:/u01/Rsync_Test/

 


  • Check weather file has been transferred or not..??

DB-SRV (192.168.32.128)


Now we can use the files as per our requirement it was done for test purpose.

Case-(app-srv to db-srv) – (oracle-oracle)—(with password)

Acctual case : -app-srv to db-srv – (weblogic-oracle)


Step4-Configure SSH to transfer file without entering password on both servers. 

  • Generate SSH public key on both servers. 


Copy generated key to Target server (where we want to copy)

In this case app-srv is source server (192.168.32.131) and db-srv is target server (192.168.32.128). 

Use below command to copy the generated key to target server.

ssh-copy-id -i /home/weblogic/.ssh/id_rsa.pub oracle@192.168.32.128


Confirm Ssh key has been configured by using below command.


Now to bypass the password will use SshPass utility to pass the password

Download rpm packages sshpass-1.06-1.el6.x86_64.rpm and install it on both servers.



FINAL – Syntax to Transfer File to Target Server from Source Server Using Rsync with Sshpass without Entering Password

Run below Command on source server (app-srv) to transfer the file on target server (db-srv).


sshpass -p 'oracle' rsync /u01/Rsync_Test/*.pdf oracle@192.168.32.128:/u01/Rsync_Test/

  



THE END

Created by - Abhishek Jha




Saturday, January 29, 2022

QR Code Tag-Length-Value (TLV) string into Base64 encoding for KSA E-Invoicing in Saudi Arabia Zakat Tax

Hello Everyone,

Link to Application -  https://apex.oracle.com/pls/apex/r/development_test01/tlv-base-64-qr/home?session=3169462546514

I have created a utility which can generate the QR code with TLV string encoded in base64 which is required for the E-Invoicing in Saudi Arab.

I got this requirement from one of my client from Kuwait. And they are using oracle forms 12c and 6i both versions and so many application and they wanted to print the QR code on invoice reports.

I had tried it with PLSQL but i didn't succeed. then i tried java because now the programming language is not a barrier for me. i just need the requirement and try to do it with the best suitable method.

That's it then i decided to help some more people for the same. as i seen so many peoples are seeking to get the information. that how they can implement this on there application.

In this blog,  i will share my understanding and the process which i followed to implement this.

--------------THE TLV FORMAT------------------------

As per Zakat, Tax and Customs Authority (ZATCA) of Saudi Arabia, one of the main requirements is the implementation of QR codes on tax invoices in the e-invoicing project (Fatoora), which will be mandatory starting December 4, 2021

As per the ZATCA instructions(Page No. 23), the minimum requirements that must be shown after scanning a QR code are the following fields, which should be represented in form of based64 encoding:

  1. Seller’s name.
  2. VAT registration number of the seller.
  3. Time stamp of the invoice (date and time).
  4. Invoice total (with VAT).
  5. VAT total.

In this blog,  I will show how to encode the QR data in base64 format using java code and then using it in any invoice to print QR code on Invoice layouts.

I am not going to provide the full code but yes i will give you the utility ( a jar file ) by which you will be able to convert normal data into tlv format then encode it in base64 and generate QR code directly with this single utility and in the output you will get a image file and you can use that image file to print it on any invoice system either the application to generate invoice can be in ORACLE FORMS, JAVA, .NET, APEX,ANGULAR and with any application.

1st Step is to prepare each of the five values in TLV (Tag-Length-Value) structure

Tag is fixed (1 for Seller’s name, 2 for VAT No……5 for VAT Total)

Length is the size of the value field in bytes (it’s not the count of characters but how many bytes the value represents)

Value is the data against each of the five fields.

Let’s take an example to clarify TLV

    1. Seller name; for example, “XYZ AAB
      • Tag      = 1 (1 as a type represents the seller name)
      • Length = 7 (The number of the bytes in “xyz AAB” word)
      • Value   = xyz AAB
    2. VAT Number; for example, 1234567891
      • Tag      = 2 (2 as a type represents the VAT number)
      • Length = 10
      • Value   = 1234567891
    3. Time Stamp; for example, 2021-11-18 08:40:00
      • Tag      = 3 (3 as a type represents invoice time stamp)
      • Length = 19
      • Value   = 2021-11-18 08:40:00
    4. Invoice Total; for example, 100.00
      • Tag      = 4 (4 as a type represents the invoice amount)
      • Length = 6
      • Value   = 100.00
    5. VAT Total; for example, 15.00
      • Tag      = 5 (5 as a type represents the tax amount)
      • Length = 5
      • Value   = 15.00

2nd Step is to convert ‘Tag’ and ‘Length’ to Hexadecimal and then to string. Then concatenate these two strings with ‘Value’ (stored as string)

concatenate all the five TLVs into one string

‘##XYZ AAB##1234567891##2021-11-18 08:40:00##115.00##15.00’

3rd Step is to convert the concatenated string to Base64 format

From the above example we get the following Base64 encoded value

AQxGaXJveiBBc2hyYWYCCjEyMzQ1Njc4OTEDEzIwMjEtMTEtMTcgMDg6MzA6MDAEBjExNS4wMAUFMTUuMDA=

4th Step is to generate the QR code of encoded string 

--------- UTILITY PART---------------------------

Development

*) written a java program to convert information in tlv format and encoding that information in base64.

*) written a java program to create QR Code image file from output string of first program.

*) downloaded and configured build path for java lib required for QR and tlv&base64 conversion.

*) combined both java programs in single code package.

*) Testing the whole logic as per KSA document standards for e-invoice.

*) created a jar file with variables for bundling all subprograms and libraries and required fields as input.

You can download this utility from below URL.

https://mega.nz/file/PW4Qna5T#kVm9gp8B7BHzbwaOHlqALoalb5EzqVVb3eZeyQfvo3Y

I named this utility as kdutility on the name of my daughters Kanak and Divya (KD).

How to use this utility to generate QR
-     Just create any directory. and place the jar utility and use below command to generate the QR code.


Open Command Prompt (cmd) for windows and terminal for  Unix/Linux.

Copy below highlighted Command and change the value for Seller_Name, Vat_Number, TimeStamp, InvoiceAmt, Vat_Amt and qr_dir ( qr_dir stands for the output directory in which you want the QR image file).

java -jar C:\Abhishek\projects\N_hdd\java_workspace2\kdutility.jar -Seller_Name "Abhishek Test" -Vat_Number 1234567891 -TimeStamp "2014-12-23 11:55:55" -InvoiceAmt 300.00 -Vat_Amt 75.00 -qr_dir C:\\Abhishek\\Oracle\\my_client\\RG_KSA_QR_TEST\\newqrcode.png

And That's it now you have the created QR image and ready to use for any invoice report.

note: - after every parameter there is a space between name of parameter and value of parameter.

And change the utility kdutility.jar path accordingly.

for example  -Seller_Name "Abhishek Jha"  - a Space before -Seller_Name and after -Seller_Name.


Example after Scanning and Output QR image for reference.


After Scanning this QR using below Android app

VAT App by the Zakat

Offered By: General Authority of Zakat and Tax-IT




Output - Screenshots 

                                                                In English Language



Output In Arabic Language



Benefits of having own utility.

*) As we are using java code so the utility is platform independent i.e., windows, Unix, Solaris etc...
*) And we can use the qr image to print on oracle reports, crystal reports etc...
*) we can also create a simple gui tool in forms ERP application to generate qr code on click event.
*) We can also replace third party utility or tools which we are currently in applications for QR codes with our own created utility by separating qr related code from our utility

*) if those third-party tools stop working and as we don't have their source code so it will impact the work. and in respect to this it will also reduce the dependency of any other third-party tools.


I can also share the source code of all above mentioned process on request or demand. 

I can also help you in implementing this functionality in your application. I did it for oracle forms 12c and 6i and printed the QR code on invoice reports.

You can also contact me for any other customization required in the utility or having issue in implementing the solutions.

 Abhishek Kumar - Abhishekjha1991@hotmail.com - only urgent.
                                  Abhishekjha225@gmail.com - for any other information.


EOD---------------------------------------------------------------- 

Buy Me a Coffee....Appreciate my work 

Phone Pay, Google Pay, Paytm etc.. - 9899406098

My Goal is to work full time on providing requested solutions and required programs code, software's etc.. and providing it to all programmers and companies in the world for free.  If you Appreciate my work then please buy me a coffee, if this utility is useful to you. And if you can't buy and still want to support me for my work Please share this page with your friends, family and coworkers if it is helpful to them.


References 
https://blogs.sap.com/2021/11/18/qr-code-in-base64-encoding-for-ksa-e-invoicing/
https://blogs.sap.com/2021/11/26/qr-code-in-base64-encoding-for-ksa-e-invoicing-directly-from-data-in-table-edosainv/
https://stackoverflow.com/questions/70346895/qr-code-in-base64-encoding-for-ksa-e-invoicing-in-java

Tuesday, November 16, 2021

Creating an OHS Instance and change default port by Using Fusion Middleware Control 12c

Creating an OHS Instance by Using Fusion Middleware Control 12c

You can create an Oracle HTTP Server instance in a WebLogic Server Domain by using Fusion Middleware Control installed as part of the Oracle Fusion Middleware infrastructure. Follow these steps.

  1. Log in to Fusion Middleware Control and navigate to the system component instance home page for the WebLogic Server Domain within which you want to create the Oracle HTTP Server instance.

  2. Open the WebLogic Server Domain menu and select Administration then Create/Delete OHS.




 

The OHS Instances page appears.



  1. Click Create.

The Create OHS Instance page appears.



  1. In Instance Name, enter a unique name for the Oracle HTTP Server instance; for example, ohs5.

  2. In Machine Name, click the drop-down control and select the machine to which you want to associate the instance.

  3. Click OK.

The OHS Instance page reappears, showing a confirmation message and the new instance. The port number is automatically assigned.

 

 

After creating the instance, the Column on the OHS Instances page shows a down-arrow for that instance.

Click on ohs5 

Start ohs5 to using start-up to use and if you want to change the port of newly created ohs as per the requirement of application see below


Editing Ports Using Fusion Middleware Control

You can edit the values for existing ports on the Fusion Middleware Control Edit Port page. To edit the ports using Fusion Middleware Control, do the following:

 

  1. Navigate to the Oracle HTTP Server home page.

  1. Select Administration from the Oracle HTTP Server menu.

  2. Select Ports Configuration from the Administration menu.

  3. Select the port for which you want to change the port number.

This is a port Oracle HTTP Server uses for its internal communication with Node Manager, in most of the cases it does not need to be changed. If you want to change it, manually edit the DOMAIN_HOME/config/fmwconfig/components/OHS/componentName/admin.conf file.

 

 

  1. Click Edit.



  1. Edit the Port number for the port.

  2. Click OK.

  3. Restart Oracle HTTP Server. 

Configure Rsync - Transferring and synchronizing files between two machines in same network

  Configure Rsync in Oracle_Enterprise_Linux6.8   Rsync is a utility for efficiently transferring and synchronizing files between a compute...