Showing posts with label Command Line. Show all posts
Showing posts with label Command Line. Show all posts

Tuesday, 13 November 2018

Let's Learn - Git Basics #2


Continuing from last post Let's Learn - Git Basics #1 where we have created the github account and a new repository. It is always a good practice to put all your code/work in one place so create a folder named something easily recognizable such as "gitCode" (in my case I have used "Git"). This will ensure that all your git code will be there for easy access.

Configuration:
Before starting to work, we will add configuration settings on our "Git" folder by executing below commands.

=
Check Configuration:
After setting up, you can view what your configurations look like by below commands -
=
=
=

Command to check Status:
To check the status of our work, GIT provides a command as below, It's very helpful while working with git - 
=
=
Working with new Repository:
a. We have already created a new repository on github named "git-learn", let's create a local repo as well.
==


b. After creating a local repository, we need to make it git repository by command "git init", this will create a hidden folder inside "git-learn" which holds all the changes done in local repository
==

c. Out git repository is ready, now let's make the first change inside it by creating a README.md file which holds the information about this repository. This is a markdown file which is used for repository documentation
==

d. After making this change, let's check the local git repo status.
==

"git status" command will display the current status of repo, Here, we can see README.md file under untracked files category (we will discuss about different type of status type later).
Untracked Files: Files about which git is not aware, as this is a new file. To push this file to remote git, we need to stage this file.

e. For staging this file, run the command as below -
==

After staging the file, we check the repo status which tells that there is a new file which has been staged to commit. But this changes hasn't been committed for push to remote repo.

f. Committing the changes is very easy and it's advisable to provide a proper comment while commit which help you in future while reviewing all the commits done on remote repo
==

g. Changes are committed, now we are good to push these changes to remote repository. But before that, as this is a new local repository, we need to tell this to which remote git repository it should commit to, Hence run the below add command, you have to run this command once per repository, so from next commit, no need to run this command unless you want to change the remote repo url.

When you push the local changes to remote, it will ask your github credentials as below (push will ask github credential every time which can be annoying and can be avoidable by setting up ssh keys with github account)
==

h. After entering github credentials, it will start pushing the data to remote git repo. 


i. When push is complete, we can check the current repo status as above.
j. You can view all the commits have been done on repository by "git log" command
==


In next post, we will see the type of changes done in git repository and how to setup password-less git repository.
Till then, Keep Loving this Blog .......... Happy Learning...........



Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Monday, 12 November 2018

Let's Learn - Git Basics #1


Github, Another awesome creation by Linux Father - Linus Torvalds. Github is an open source Code repository management service/tool which provides you ease of parallel development without any hassle and care to maintain the code versions and merge issue. If you want to know, read and learn here - https://lab.github.com

Git Basics #1:

1. If you are new to Github, Create your account first on https://github.com
 

2. After creating your account, create a new repository by clicking on  "New" button

3. Fill the Repository Name and descriptions as below -

You can initialize the README file and add the other files but I haven't done it as will add them from command line.

4. Once your repository has been created, Github shows you these commands to replicate the repo and use them in your local system.


If Repository is new -

If this is existing repository (which is not as we have created it just now)


Installing Git Client

1. Go to git-scm link - https://git-scm.com/downloads and choose Git client for your OS.
2. For windows users, It's pretty straight forward to download the client and install it as regular software.
3. For Linux users, It's little tricky as different linux distro have different software management or repository and command line to install it. But Git also take care of all the commands for most popular linux distro on this link - https://git-scm.com/download/linux

Once, You have the Git Client and Git Account Setup, We can start with the basics with #2 post.






Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Tuesday, 30 October 2018

Converting PFX Certs to Certificate and Key Files using OpenSSL



Recently, I have an ask where we want to automate Web Service Health Check manual steps. I have choose Python to do that (Cause one only my fav language :-) but faced a very initial hiccup as PFX certs. As our web services are SSL enabled which need Public/Private Key (Or Certificate) to authenticate the Consumer and Python supports certificates and keys only in PEM format.

So let's learn how we can convert PFX (Personal Information Exchange) certs to PEM (Privacy Enhanced Mail) certificate.



  • Extract certificate.pem or certificate.cer from certificate.pfx:
  • -


  • Extract Key - 
This is 2 step process as below, first command extract the encrypted key and then second command use to decrypt the key to simple text.
-


Now, we can use these keys in our Python Health Check code, we will discuss that later.
Till then, Keep Loving this Blog .......... Happy Learning...........



Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Friday, 21 September 2018

Get HTTPS and SSL details of App Deployed - IIB/WMB SCRIPTS


One more to get the HTTPS and SSL details from an Application Deployed in IIB -


- -





Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Wednesday, 5 September 2018

Create Alias Command with Parameter in Linux


"Alias" - A shortcut for a command or set of commands

Linux OS provides the facility to have alias command to keep the long and frequent command to very few keystrokes, May be I am being a more cryptic with the lots of jargon words, let's try to understand this way -

When you execute a command "ll" (double Ele) in Linux prompt, it will return the result which is the same as "ls -l" because most of the modern linux os have this alias command (ll) for "ls -l" which is quick and easy.  You can add your customize command in ".bashrc" (dot bashrc) in case of  BASH shell or ".kshrc" in case of KORN shell.



How To:
alias pcs = 'ps -ef'  # this will create an alias named pcs which is equivalent to "ps -ef"

As we can see, we can create lots of alias of frequent commands needed in our day to day work, but avoid the alias which modifies/delete system files.

Now, Coming back to the Original Topic,  Can we create an alias which accepts the arguments, Answer is YES, lets check it our How To --

How To create ALIAS which accept command line parameter:


  • Create a script which will accept the argument and do the task, such as - 
= =

  • Create an alias for this script as - 
==

  • How to use this alias - 
==

and voilĂ  !! we are done, Now you can add so many scripts as alias which accept the parameters, Please share here if you have created something useful for you.





Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Saturday, 3 February 2018

Jupyter Lab Env - Quick Start Script


Every Data Analyst, who is working in Python, is very well aware of Jupyter or Jupyter Lab. 


Sometime it seems little annoying, to lazy person like me, to start the Command Prompt, go to your working code directory and type jupyter command to start the notebook.

To avoid this burden I have wrote a small batch script which will do the task for me in one click. Sharing here the same, Lazy Programmers, please share this post if you like it :-)



For Better View, Click on "View Raw"




Like the below page to get update  
https://www.facebook.com/datastage4you
https://twitter.com/datagenx
https://plus.google.com/+AtulSingh0/posts
Join Telegram DataStage4You Group

Sunday, 19 November 2017

Get Job Parameters for all DataStage Job


Feels awesome while writing this post after 7 week, In this post I am going to share a script which will fetch the job parameters for all the datastage job available in given project.

This week, one of my colleague ask to compare all the jobs parameter from one project (older) to another project (migrated),  So, wrote down this script which worked like charm for me and hoping will work for you as well :-)





=


Like the below page to get update  
https://www.facebook.com/datastage4you
https://twitter.com/datagenx
https://plus.google.com/+AtulSingh0/posts
https://datagenx.slack.com/messages/datascience/

Thursday, 13 July 2017

How to Run Python Code in NotePad++


Can you run the python code from NotePad++ ?? Question seems to be little odd but we can tweak our notepad++ settings and configure it that way. Let's see how -



1. Write few line as your python code, You can use below lines-

print("Today we are going to learn how to use notepad++ to run the python code")
print("As first step, we have to write few python code line")

input("Press Enter to Exit..........")




2. Save this file, in my case, it is saved as "npp_run.py"
3. Check the python executable path in your system. In my case it is - C:\tools\Anaconda3\python.exe  (It can be different as per your python installation)

4. Now go to Run menu or Press F5. This will open a run window as below -

5. Python below code in 'the program to run' -
Python_Executable_Path $(FULL_CURRENT_PATH)
C:\tools\Anaconda3\python.exe $(FULL_CURRENT_PATH)



6. Save this Run configuration by clicking on Save button on same window

7. Choose Run button combination (can use Ctrl + Alt + Shift + Key) and Save.

8. You can see this combination under Run Menu.


9. Now, You can run the Python code by pressing the combination buttons (My case - F9)




Things to Remember:
1. This tweak is not replacement for Python IDE :-) such as PyCharm, Spider or many others.
2. Always put the  input("Press Enter to Exit..........")at very last line of your code else you will not able to see the python code output.




Like the below page to get update  
https://www.facebook.com/datastage4you
https://twitter.com/datagenx
https://plus.google.com/+AtulSingh0/posts
https://datagenx.slack.com/messages/datascience/

Tuesday, 20 June 2017

Crontab for Windows #iLoveScripting


While working on one of my project, I required to take backup of all the work which I have completed coz workplace is shared among many developers.
     So being a Linux person, I was looking for something simple like Crontab but ended with Windows Task Scheduler. 

Tool is simple but not as Linux Crontab But it did the work asked by me :-)

How to Use Task Scheduler - 

  • Login with Admin privilege user account  
  • Open Run and "Taskschd.msc"
  •  Or  Go to Start --> Control Panel --> System and Maintenance --> Administrative Tools --> Task Scheduler
  • Click on "Create Task" on right hand side
  • This will open a Wizard to create Task
  • Fill the Task Name, Owner, Privilege and Configured for as below - 
  • Now, Click on Next Tab - Trigger, Here you have to define the time when you want to execute the program
  • You can fill the different Setting to customize your schedule.
  • Now, Click on "Action Tab"
  • In this tab, you have to define the action, such as when triggered what program/script should be execute
  • Click OK
  • You can see your task created under "Task Scheduler Library"


For More details on Task Scheduler, You can visit below links -
https://technet.microsoft.com/en-us/library/cc748993(v=ws.11).aspx




Like the below page to get update  
https://www.facebook.com/datastage4you
https://twitter.com/datagenx
https://plus.google.com/+AtulSingh0/posts
https://datagenx.slack.com/messages/datascience/