Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sugata_bagchi2
Active Contributor
Introduction:

At some point of time we all came across a scenario or requirement where we needed to develop an interface where we had to create scripts to perform some additional tasks. e.g - rename source files after processing them, zip the source files,add time stamp to the source file once processed etc. We used either batch script or unix shell scripts based on the environment of the system (Windows or Unix).

In this blog I will share an opensource tool using which we can easily create and test Unix shell scripts.

Issue Description:

UNIX OS level scripts are always not easy to create and test in a standalone mode, using the local windows based machine. We have to upload the shell script file every time in the sever and then can test it by referring the script path in the PI channel. Today I will share some details on GIT bash tool using which we can easily create and test the UNIX shell scripts.

Tool Link:


There are tools like - cygwin, winbash etc. but the Git-Bash tool is pretty easy to configure and use compared to others.

We can download the tool from this link -  https://git-scm.com/download/win

This tool  is released under the GNU General Public License version 2.0, which is an open source license

Installing the tool:

Installing the tool is very easy and standard. Please follow the steps and standard checks -

1.



2.  Check the Vim editor-

3.

4.

5.

Then click to standard install. I will create a desktop Icon and you are ready to go.

 

Using the Tool:

Once the tool is installed you can use it just by opening the console or by double clicking the desktop icon.


You can run any unix command to test it -



Creating and testing a Shell script:

Using Git Bash, one can create and execute the script in any directory context by opening it as mentioned below - this way the script will be written and can be test in the Test directory



once the git bash is opened, type below and hit enter- here abc.sh is the example shell script file.After this hit insert button to write the code-

vim abc.sh



You can write the sh code here -



to save the file press Esc key and the press  : and x, after this hit enter, this will save the code to the file and create a file in that context directory.



Once the file is saved, you can assign the execute authorization to the file as below -

$ chmod a+x abc.sh   where abc.sh is your script file name.

To run the file use the below command -  ./abc.sh where abc.sh is your file name. here I have provided GitBashTool as parameter to the script.



That's it!

 

Conclusion:

This tool will help us a lot to develop and test UNIX scripts very easily on Windows based machines. It does not require any  complex settings / setup while installing this. Pretty easy to configure.

Using this tool we can directly test the script without uploading it to SAP servers.

Reference: Instead of vim editor, you can also use nano editor. Here is the link for basic use of nano editor - https://wiki.gentoo.org/wiki/Nano/Basics_Guide

If you are missing any libraies in the Git Bash version you are using, you can follow the steps from this link to add them -

https://ranxing.wordpress.com/2016/12/13/add-zip-into-git-bash-on-windows/

 

Hope this will help the community!
Labels in this area