Posts

Showing posts from 2022

Linux: How to scan remote host for open ports ?

Linux : How to find a remote port is opened or not ? Helllo Team, If you are trying to findout whether a remote server port is opened or closed, then there are so many ways. Here In this article I am posting on same using telnet and nc commands. Using telnet Telnet usually holds prompt, so to avoid that, we are using echo in front of the command. > $ echo | telnet xxxxxx 22 Trying xxxxxx .. . Connected to xxxxx. Escape character is '^]' . Connection closed by foreign host. Using nc with nc command, its direct. > $ nc -z -v -u xxxxx 22 Connection to xxxx port 22 [ udp/ssh ] succeeded ! # -z: Just perform scans without sending any data to the respective service running on the given port. # -v : Verbose # -u: UDP packets, without this it will be default tcp. Hope it helps. Thanks

ServiceNow: How to read the content of a text file from an incident record attachment

How to read the content of a text file from an incident record attachment:   GlideSysAttachment API is used to handle attachments. With this API, we can copy attachment from one record to another read the content of a attached file as text, base64 or content stream write the content read all attachments of a record and also we can delete any of the attachment of a record var attachment = new GlideSysAttachment (); var incidentSysID = '136e85931bc8fc1037fc4263cc4bcb46' ; var agr = attachment . getAttachments ( 'incident' , incidentSysID ); gs . info ( agr . getRowCount ()); while ( agr . next ()) { var attachmentContent = attachment . getContent ( agr ); gs . info ( 'Attachment content: ' + attachmentContent ); Output: x_67546_crusher: Attachment content: Vamshi Vemula Staff software Engineer  

OS Internals: Interprocess Communication ( IPC)

Image
ipc Interprocess Communication ( IPC ) Interprocess communication allows a process to communicate with another process. Communications can be one of two types Between related process ( parent and child ) Between unrelated processes ( one or more different processes) IPC can use Pipes First In First Out ( FIFO) - Queue Message Queues Shared Memory Semaphores Signals

Python Notes - Strings

Python Notes String Methods string.capitalize() Capitalized first letter of string. string.strip() Strips whitespaces both left and right side. string.lstrip() Strips whitespaces left side string.rstrip() Strips whitespaces right side string.lower() turns string into lower case string.upper() turns string into upper case string.split() Split string into array String Formatting Formatting using %{s,i} In [24]: import time In [25]: time.strftime("%H:%M:%S") Out[25]: '21:19:12' In [26]: # Method 1 In [27]: print("Hello %s, current time is %s" % ("Raja", time.strftime("%H:%M:%S"))) Hello Raja, current time is 21:20:22 In [28]: # Method 2 In [30]: print("Hello %(name)s, current time is %(time_now)s" % { "name"

JavaScript: Understanding Prototype and Class methods

Image
So, in JavaScript, first of all, its an object oriented programming but without classes (till ES5), now with ES6 we have classes officially in JavaScript But still the old behaviour of the language is forwarded with newer version In Javascript creating an object is possible via its functions( new [Func]()), function is a first class (can be passed as an argument), function is a high order function(can be received as an argument), function it self acts a constructor( new func() ) take a look at below code function User(name, passwd) { this.name = name; this.passwd = passwd; this.methodname = "User" } u1 = new User("User1", "Password") u2 = new User("User2", "Password") console.log(u1) console.log(u2) User.prototype.method1 = function () { console.log("This is method1"); } u1.method1() User.method2 = function() { console.log("this is method2"); } User.me

GoLang: How To work with JSON Data and Nested structs

GoLang: How To work with JSON Data and Nested structs Hello Everyone, I spent sometime today to craft this code, so this article slowly walk you through how to build a nested struct, how to load data into it, then converting it into JSON, writing to a file, reading from a file and append new data etc. I was learning GoLang and found needed something like this. Hope it helps. package main import ( "encoding/json" "fmt" "os" ) type Schema struct { Users map [ string ] User Posts map [ string ] Post } type User struct { Username string `json:"username"` Email string `json:"email"` } type Post struct { Heading string `json:"post_heading"` Description string `json:"description"` } func main ( ) { u1 := User { Username : "rajag" , Email : "rajag@example.com" , } p1 := Post { Heading : "Post 1 he