Found 27104 Articles for Server Side Programming

What is the search() function in Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 10:29:09

11K+ Views

Python is renowned for its adaptability and potency as a programming language, equipping developers with an extensive array of functions and methods to handle strings, pattern searches, and a variety of text-related operations. Among these functions lies 'search()', an integral component of the 're' (regular expression) module. This comprehensive article delves into the depths of the 'search()' function in Python, presenting step-by-step elucidations and practical code examples to unravel its usage. Consequently, enabling you to become proficient in employing regular expressions for text search operations in Python. Comprehending Regular Expressions Before delving into the specifics of the 'search()' function, it ... Read More

What is the match() function in Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 10:26:48

12K+ Views

In the realm of Python programming, text manipulation, and pattern matching are tasks that programmers frequently encounter across various applications. Python, known for its versatility and power, provides numerous tools and modules that facilitate string operations and pattern matching. Among these essential tools lies the match() function, a part of the ‘re’ module in Python, which grants developers the ability to conduct pattern matching using regular expressions, thereby offering a robust means of searching for patterns specifically at the beginning of strings. This comprehensive article aims to explore the match() function, elucidating its purpose, usage, and practical code examples replete ... Read More

What is the simplest way to SSH using Python?

Pranathi M
Updated on 11-May-2023 14:34:49

4K+ Views

SSH (secure shell) is helpful for remotely managing computers in a secure manner. To connect to a server, you typically use PuTTy, MobaXTerm, or the command-line ssh application. Every Unix, Linux, and Mac server includes SSH as standard equipment, and it is usable in every data centre. SSH connections have made it feasible for secure remote access to resources, remote command execution, the transmission of software patches and updates, and other administrative or management tasks. SSH is used in systems administration and file transfer software, as well as to handle routers, server hardware, virtualization platforms, and operating systems (OSes). Additionally, ... Read More

How to perform different commands over ssh with Python?

Rajendra Dharmkar
Updated on 18-Feb-2020 07:15:27

1K+ Views

The simplest way to use SSH using python is to use paramiko. You can install it using −$ pip install paramikoTo use paramiko, ensure that you have correctly set up SSH keys(https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html) on the host machine and when running the python script, these keys are accessible. Once that is done use the following code to connect to a remote server using ssh −from paramiko import SSHClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect('user@server:path') ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('ls') print(ssh_stdout) #print the output of ls commandYou can use the exec_command function to run any command supported by the server you're connected to over ... Read More

How to use FTP in Python?

Rajendra Dharmkar
Updated on 18-Feb-2020 07:14:33

280 Views

You can use the ftplib module in Python. It allows you to write programs that perform a variety of automated FTP jobs. You can easily connect to a FTP server to retrieve files and process them locally.exampleimport ftplib ftp = ftplib.FTP('ftp.yourserver.com', 'yourusername', 'your@email.address') print "File List: " files = ftp.dir() print(files) ftp.cwd("/tmp") #change working directory to /tmpAbove code connects to a FTP server and prints the file list in the home directory of that server.

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

Rajendra Dharmkar
Updated on 18-Feb-2020 07:10:47

13K+ Views

The easiest way to copy files from one server to another over ssh is to use the scp command. For calling scp you'd need the subprocess module. exampleimport subprocess p = subprocess.Popen(["scp", "my_file.txt", "username@server:path"]) sts = os.waitpid(p.pid, 0)You need the waitpid call to wait for the copying to complete.Another solution is to open a ssh connection and use the scp module.  examplefrom paramiko import SSHClient from scp import SCPClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect('user@server:path') with SCPClient(ssh.get_transport()) as scp:     scp.put('my_file.txt', 'my_file.txt') # Copy my_file.txt to the serverRead More

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

Rajendra Dharmkar
Updated on 16-Dec-2019 07:53:53

8K+ Views

The easiest way to copy files from one server to another over ssh is to use the scp command. For calling scp you'd need the subprocess module.For exampleimport subprocess p = subprocess.Popen(["scp", "my_file.txt", "username@server:path"]) sts = os.waitpid(p.pid, 0)You need the waitpid call to wait for the copying to complete.Another solution is to open a ssh connection and use the scp module.For examplefrom paramiko import SSHClient from scp import SCPClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect('user@server:path') with SCPClient(ssh.get_transport()) as scp:     scp.put('my_file.txt', 'my_file.txt') # Copy my_file.txt to the serverRead More

How to get the maximum file name length limit using Python?

Rajendra Dharmkar
Updated on 08-Sep-2023 13:25:24

1K+ Views

In the ever−evolving world of software development, understanding and being aware of the limitations of various file systems and operating systems is very critical. One such limitation that developers often encounter in their work is the maximum file name length limit. Various file systems and platforms have varying restrictions on the length of file names, and this can hugely impact the way we handle and store files in our applications. In this comprehensive article, we will explore various ways how to use Python to determine the maximum file name length limit on different systems. We will be providing a few ... Read More

What is the maximum file size we can open using Python?

Rajendra Dharmkar
Updated on 08-May-2023 12:07:38

2K+ Views

In Python, the maximum file size that can be opened depends on the operating system and the filesystem. In general, modern operating systems and filesystems support very large file sizes, so the practical limit is often much higher than what you would ever need. For example, on a 64-bit version of Windows or Linux with NTFS or ext4 filesystems, the maximum file size is several exabytes (1 exabyte is 1 billion gigabytes). This is far beyond the capacity of current storage devices and most applications, so it's unlikely to be a limiting factor in practice. In Python, you can open ... Read More

How to extract all the .txt files from a zip file using Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 11:36:29

1K+ Views

Multiple files can be compressed and stored together using ZIP archives, which are common in the area of data manipulation and file management. Python offers a number of modules to work with ZIP files without any issues because it is a flexible and strong language. The requirement to extract particular files from a ZIP archive, such as all the.txt files, is a frequent activity. This in-depth article will examine the procedure for using Python to extract every.txt file from a ZIP package. A few real-world examples of code will be provided to illustrate the process as we go through the ... Read More

Advertisements