Found 33676 Articles for Programming

How to perform different commands over ssh with Python?

Niharikaa Aitam
Updated on 20-Jun-2025 19:15:44

2K+ Views

When we want to remotely access and execute commands on another machine then we use the paramiko library in Python. Paramiko is a third-party library that is used to connect and communicate securely with remote machines using the SSH, i.e., Secure Shell protocol. It allows us to execute commands, transfer files, and perform other remote tasks programmatically. To use the Paramiko library, first we need to install it in our local system using the below command - pip install paramiko Example Following is the example, in which we connect to a remote server via SSH and perform multiple shell ... Read More

How to count unique elements in the array using java?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:20

1K+ Views

The interface Set does not allow duplicate elements, therefore, create a set object and try to add each element to it using the add() method in case of repetition of elements this method returns false − If you try to add all the elements of the array to a Set, it accepts only unique elements − Example import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class CountingUniqueElements { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter the size ... Read More

How to use FTP in Python?

SaiKrishna Tavva
Updated on 13-Nov-2024 12:47:27

480 Views

In Python we can use FTP (File Transfer Protocol) by importing the ftplib module, it will provide a simple interface to access FTP servers to retrieve files and process them locally. ftplib module allows us to write Python programs that perform a variety of automated FTP tasks. Objectives of FTP The objectives of FTP are as follows FTP provides file sharing. FTP helps us to encourage the use of remote computers. FTP is used to transfer the data reliably and efficiently. Some Common tasks we can perform using FTP in Python by utilizing the 'ftplib' module are as follows: ... Read More

How to find numbers in an array that are greater than, less than, or equal to a value in java?

Srinivas Gorla
Updated on 16-Jun-2020 09:36:58

4K+ Views

You can find numbers in an array that are greater than, less than, or equal to a value as:ExampleLive Demopublic class GreaterOrLess {    public static void main(String args[]) {       int value = 65;       int[] myArray = {41, 52, 63, 74, 85, 96 };       System.out.println("Elements of the array that are equal to the given value are::");       for(int i = 0; i

How to store a 2d Array in another 2d Array in java?

Abhinanda Shri
Updated on 19-Feb-2020 11:22:53

3K+ Views

Create an array to which you want to store the existing array with the same length. A 2d array is an array of one dimensional arrays therefore, to copy (or, to perform any operation on) the elements of the 2d array you need two loops one nested within the other. Where, the outer loop is to traverse through the array of one dimensional arrays and, the inner loop is to traverse through the elements of a particular one dimensional array.Examplepublic class Copying2DArray {    public static void main(String args[]) {       int[][] myArray = {{41, 52, 63}, {74, ... Read More

How to copy a file to a remote server in Python using SCP or SSH?

Niharikaa Aitam
Updated on 20-Jun-2025 19:16:33

16K+ Views

When we want to transfer files from our local system to a remote server securely, Python provides possible ways to do the file transfer using the Paramiko and SCP libraries. These libraries support SSH-based file transfer, which is secure and reliable. Installing Required Libraries Before we start with file transfer, we need to install all the required libraries with the help of below commands - pip install paramiko scp Using paramiko and SCP/SSH Paramiko is a third-party library available in Python, which is used to transfer a file to a remote server without using an external SCP module. This ... Read More

Can we overload the main method in Java?

radhakrishna
Updated on 30-Jul-2019 22:30:20

3K+ Views

Yes, we can overload the main method in Java, but When we execute the class JVM starts execution with public static void main(String[] args) method. Example Live Demo public class Sample{ public static void main(){ System.out.println("This is the overloaded main method"); } public static void main(String args[]){ Sample obj = new Sample(); obj.main(); } } Output This is the overloaded main method

How to copy files from one server to another using Python?

Niharikaa Aitam
Updated on 20-Jun-2025 19:31:03

9K+ Views

Transferring files from one server to another is a most common task in system administration, DevOps and development workflows. The tools such as scp and rsync are used for the file transfer. Python provides different methods and tools to transfer the files from one server to another using a third party libraries such as paramiko and SCPClient. Using Paramiko and SCP for Secure Transfers When we want to copy files securely from one server to another using Python, we can use the libraries Paramiko and SCPClient together. Paramiko is a Python library that helps to implement SSHv2 protocol. This is ... Read More

Why is method overloading not possible by changing the return type of the method only in java?

mkotla
Updated on 30-Jul-2019 22:30:20

3K+ Views

Overloading is the mechanism of binding the method call with the method body dynamically based on the parameters passed to the method call. If you observe the following example, it contains two methods with same name, different parameters and if you call the method by passing two integer values the first method will be executed and, if you call by passing 3 integer values then the second method will be executed.It is not possible to decide to execute which method based on the return type, therefore, overloading is not possible just by changing the return type of the method. Example ... Read More

What is method hiding in Java and how to use it?

Giri Raju
Updated on 30-Jul-2019 22:30:20

2K+ Views

When super class and sub class contains same method including parameters and if they are static. The method in the super class will be hidden by the one that is in the sub class. This mechanism is known as method hiding. Example Live Demo class Demo{ public static void demoMethod() { System.out.println("method of super class"); } } public class Sample extends Demo { public static void demoMethod() { System.out.println("method of sub class"); } public static void main(String args[] ) { Sample.demoMethod(); } } Output method of sub class

Advertisements