Thursday, December 27, 2018

Using Zypper and RPM to install ,uninstall and manage packages ,patches and updates on SUSE Enterprise Linux,Linux Teacher Sourav,Kolkata 08910141720

install something

sudo zypper install packagename

it will install the package with the dependancies

for example to install git-core

sudo zypper install git-core


now to remove the package

sudo zypper remove git-core


as you might seee when installing the git-core package
you have  a dependency called perl-error which was installed
but this is not removed when using sudo zypper remove git-core

so to remove it manually

 sudo zypper remove perl-Error

however let us do the proper way of removing a package with the dependencies

lets install git-core again

 sudo zypper install git-core

after installing we need to use this to remove git-core as well as
the dependency perl-error

sudo zypper rm --clean-deps git-core


to see all our missing dependecies

 sudo zypper verify

this will most likely solve any dependency issue the system is having

to get the necessary patches/updates

sudo zypper patch



to include the optionalpatches

sudo zypper patch --with-optional


to get a summary list of security patches recommended patches

and optional patches


sudo zypper patch-check

the difference between patches and updates is

patches which are mostly associated with kernel are generally
backward compatible

but updates are not always backward compatible

to list all the patches

sudo zypper list-patches

to update the system

sudo zypper update

after update to reflect the changes to some files

sudo zypper ps -s

to see if there is any more update to perform

sudo zypper list-updates

to get information about a package

rpm -q -i wget


to list all the files in the package

 rpm -q -l wget

to see all the documentation files in a package

rpm -q -d wget

to see all the configuration files in a package

rpm -q -c wget

to see the scripts those are used for installing and uninstalling

rpm -q --scripts wget











Managing repositories in SUSE Enterprise Server,Linux Teacher Sourav,Kolkata 08910141720

list repositories
zypper lr

the output will show the current repositories


to get more detailed out about repositories

zypper repos -d

to add your own or any generic repository

sudo zypper addrepo http://example.com/repo myrepo

here myrepo is the alias of this repo


now to see if this new repo is added

zypper lr


now to remove this repo

we can do this

sudo zypper removerepo 7

this number is for myrepo ,we can see this number by the command

zypper lr


to check if the new repo is removed or not

zypper lr

we could have removed the repo by using the alias in place of number

sudo zypper removerepo myrepo

Monday, December 24, 2018

Nice terminal trick if you forget to put sudo before a command,Linux Teacher Sourav,Kolkata 08910141720

Sometimes a command need sudo before it as it requires permissions,we can write 

sudo !!

that will run the last command with sudo appearing in front of it

Find the age of my suse enterprise linux system,Linux Teacher Sourav,Kolkata 08910141720

I have a trial of suse enterprise linux server which gives me two months to play around,I want to know how many days have gone by after installation ,this is the way worked for me

ls -alp /etc/ssh/ssh_host_dsa_key.pub | cut -d " " -f6


Source:https://serverfault.com/questions/221377/how-to-determine-the-age-of-a-linux-system-since-installation

Wednesday, December 5, 2018

Creating Dynamic Reports from Excel Data using VBA,VBA Teacher Sourav,Kolkata 08910141720

Dim sdsheet, ersheet As Worksheet

k = ActiveWorkbook.Sheets.Count

    For i = k To 1 Step -1
        t = Sheets(i).Name
        If t = "Emp_rpt_insurance" Then
            Application.DisplayAlerts = False
                Sheets(i).Delete
            Application.DisplayAlerts = True
          
        End If
    Next i
On Error Resume Next
  ActiveWorkbook.Sheets.Add(After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)).Name = "Emp_rpt_insurance"
Set sdsheet = ThisWorkbook.Sheets("Sortsheet")
Set ersheet = ThisWorkbook.Sheets("Emp_rpt_insurance")
If sdsheet.Cells(Rows.Count, 1).End(xlUp).Row = 1 Then
sdlr = 2
Else
sdlr = sdsheet.Cells(Rows.Count, 1).End(xlUp).Row
End If
y = 2

ersheet.Cells(1, 1) = "Emp ID"
ersheet.Cells(1, 2) = "First Name"
ersheet.Cells(1, 3) = "Last Name"
ersheet.Cells(1, 4) = "Address"
ersheet.Cells(1, 5) = "Zipcode"
ersheet.Cells(1, 6) = "Mail"
ersheet.Cells(1, 7) = "Date Of Birth"
ersheet.Cells(1, 8) = "Phone"








For x = 2 To sdlr
If (UCase(sdsheet.Cells(x, 14)) = "A") And (CInt(sdsheet.Cells(x, 17)) >= 40) Then
ersheet.Cells(y, 1) = sdsheet.Cells(x, 1)

ersheet.Cells(y, 2) = sdsheet.Cells(x, 2)

ersheet.Cells(y, 3) = sdsheet.Cells(x, 3)

ersheet.Cells(y, 4) = sdsheet.Cells(x, 5)

ersheet.Cells(y, 5) = sdsheet.Cells(x, 9)

ersheet.Cells(y, 6) = sdsheet.Cells(x, 12)

ersheet.Cells(y, 7) = sdsheet.Cells(x, 15)

ersheet.Cells(y, 8) = "XXX-XXX-" & Right(sdsheet.Cells(x, 10), 4)

y = y + 1
End If



Next x


ersheet.Cells.Columns.AutoFit

'If ersheet.Cells(Rows.Count, 1).End(xlUp).Row = 1 Then
'erlr = 2
'Else
'erlr = ersheet.Cells(Rows.Count, 1).End(xlUp).Row
'End If
'

Tuesday, December 4, 2018

Determine employee is eligible for insurance using datediff and Iif function in VBA,VBA Teacher Sourav,Kolkata 08910141720

I have an employee list with their date of birth ,I need to calculate whether they are below or above 40 years old  to determine if they are eligible for insurance,here is the vba code for that

If IsDate(Application.WorksheetFunction.VLookup(Me.Label1, [Emplist_dob], 15, 0)) Then

Label6.Caption = IIf(DateDiff("yyyy", Application.WorksheetFunction.VLookup(Me.Label1, [Emplist_dob], 15, 0), Date) >= 40, "Above 40 no insurance", "Below 40 eligible for insurance")

End If

Saturday, December 1, 2018

Get Historical Data from NSE using VBA and Internet Explorer,VBA Teacher Sourav,Kolkata 08910141720


Public Sub downloadData()
'Open an excel sheet and rename one of the sheets as "DailyData". The data will be
'copied to that sheet

Dim frmDate As String, toDate As String, scrip As String
frmDate = DateSerial(2017, 5, 22)
frmDate = Format(frmDate, "dd-mm-yyyy")
toDate = DateSerial(2017, 5, 26)
toDate = Format(toDate, "dd-mm-yyyy")
scrip = "DABUR"
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("DailyData")

'Call subroutine to download the data
getNSE_post frmDate, toDate, 1, 1, scrip, ws

End Sub


Sub getNSE_post(frmDate As String, toDate As String, nRow As Integer, _
nCol As Integer, scrip As String, ws As Worksheet)
Dim str As String
Dim ie As Object
Dim frm As Variant
Dim element, submitInput As Variant
Dim rowCollection, htmlRow As Variant
Dim rowSubContent, rowSubData As Variant
Dim i, j, k, pauseTime As Integer
Dim anchorRange As Range, cellRng As Range
Dim start

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "https://www.nseindia.com/products/content/equities/equities/eq_security.htm"
While ie.readyState <> 4: DoEvents: Wend

'try to get form by ID
Set frm = ie.document.getElementById("histForm")

ie.Visible = True
ie.document.getElementById("dataType").Value = "priceVolumeDeliverable"
ie.document.getElementById("symbol").Value = scrip
ie.document.getElementById("segmentLink").Value = 3
ie.document.getElementById("symbolCount").Value = 1
ie.document.getElementById("series").Value = "EQ"
'ie.document.getElementById("dateRange").Value = "day"
ie.document.getElementById("rdPeriod").Checked = True
ie.document.getElementById("fromDate").Value = frmDate
ie.document.getElementById("toDate").Value = toDate

'Pause For User To See Entry
pauseTime = 2 ' Set duration in seconds
start = Timer ' Set start time.
Do While Timer < start + pauseTime
DoEvents ' Yield to other processes.
Loop

For Each submitInput In ie.document.getelementsbytagname("INPUT")
If InStr(submitInput.getAttribute("onclick"), "submitData") Then
submitInput.Click
Exit For
End If
Next


 k = ActiveWorkbook.Sheets.Count

    For i = k To 1 Step -1
        t = Sheets(i).Name
        If t = "Full Table" Then
            Application.DisplayAlerts = False
                Sheets(i).Delete
            Application.DisplayAlerts = True
           
        End If
    Next i
On Error Resume Next
  ActiveWorkbook.Sheets.Add(After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)).Name = "Full Table"
  
Set anchorRange = Sheets("Full Table").Cells(1, 1)
i = 0 'The header row needs to be omitted

Set rowCollection = ie.document.getelementsbytagname("tr")
For Each htmlRow In rowCollection
Set rowSubContent = htmlRow.getelementsbytagname("td")
k = 0
For Each rowSubData In rowSubContent

anchorRange.Offset(i, k).Value = rowSubData.innerText
k = k + 1


Next rowSubData

i = i + 1
Next htmlRow

End Sub



Maximize minimize and random size of internet explorer window using VBA,VBA Teacher Sourav,Kolkata 08910141720

 Declare Function apiIEsize Lib "user32" Alias "ShowWindow" _
(ByVal hwnd As Long, ByVal CmdShow As Long) As Long

Global Const SW_MAXIMIZE = 3
 Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2

Sub differntIEsize()

Set ie = CreateObject("InternetExplorer.Application")

 ie.Visible = True
apiIEsize ie.hwnd, SW_MAXIMIZE

ie.navigate "https://www.google.com"

 End Sub 



Source:https://www.youtube.com/watch?v=Kiro_vuS6Bo&index=4&list=PLe_F6wC3Fvdrh3aUyLExNcuofDAmb0nGV