[Python] Search a file with paramiko


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Python] Search a file with paramiko
# 1  
Old 05-19-2014
Linux [Python] Search a file with paramiko

I need to compare the output files in a directory for sftp, looking through a mask.

Return the full file name.

Eg.

I have a file named locally:

test.txt

I must check through sftp, if a file with the following name:

test_F060514_H173148.TXT

My idea is for the filename to a variable, without the extension .TXT.


Code:
dirlistTestigos = os.listdir(testigos)
            for j in dirlistTestigos:
                fileName, fileExtension = os.path.splitext(j)
                fileNameMask = '/datos/' + fileName + '_F*'

How I can check if a file with the mask, exists in a directory on a remote sftp?






is this correct? :



Code:
fileNameComp = sftp.listdir(fileNameMask)

the use of the mask, you do not know what date and time the file might have the name.

Moderator's Comments:
Mod Comment edit by bakunin: please use CODE-tags! You have read the rules and the warnings when opening this thread as well as the FAQ, didn't you?

Last edited by bakunin; 05-19-2014 at 12:19 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Python Paramiko multi threading to capture all output for command applied in loop

My issue : I am getting only last command output data in ouput file. Though comamnd "print(output)" displays data for all 3rd column values but the data saved in file is not what required it hs to be the same which is being printed by command"print(output)". Could you please help me to fix this,... (0 Replies)
Discussion started by: as7951
0 Replies

2. Programming

Search or find a element inside list python

I have a list as follows: From this i need to grep the element using keyword as "primary" and return output as 12:13-internet-wifi-primary i used as follows if (i <= (len(system_info))): ss = system_info print... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies

3. Shell Programming and Scripting

sed command inside paramiko python

Hi I am trying to execute a sed command inside paramiko which finds and deletes the particular string from a file But sed command doesnt work inside paramiko python machine=qwe dssh = paramiko.SSHClient() dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

4. Programming

Python re.search vs re.sub

I am having trouble understanding why these two commands differ with one producing the desire results and the other not. An example: capture_str = 'xserver-xorg-video-qxl-dbg (0.1.1-2+b2 , 0.1.1-2+b1 , 0.1.1-2 ) X.Org X server -- QXL display driver (debugging symbols)' re.search(r'(?<=\\, ).*',... (2 Replies)
Discussion started by: metallica1973
2 Replies

5. Shell Programming and Scripting

Search and Replace+append a text in python

Hello all, I have a verilog file as following (part of it): old.v: bw_r_rf16x32 AUTO_TEMPLATE ( 1957 // .rst_tri_en (mem_write_disable), 1958 .rclk (clk), 1959 .bit_wen (dva_bit_wr_en_e), 1960 .din ... (5 Replies)
Discussion started by: Zam_1234
5 Replies

6. Shell Programming and Scripting

Paramiko Script

Hi Geeks, I have the following python script. #!/usr/bin/python #Script to pull KPI values from MMEs. import paramiko import sys import os host = sys.argv user = sys.argv password = sys.argv ssh = paramiko.SSHClient() (8 Replies)
Discussion started by: infinitydon
8 Replies

7. Shell Programming and Scripting

Retrieving the relevant search from search file in the main file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search... (7 Replies)
Discussion started by: csim_mohan
7 Replies

8. Programming

Search for a File Python

I am back at it with Python and have run into a little stupid hurdle. My goal is to simply search for the GeoIP.dat database and add the path to a couple of variables. So for example: geopath=os.system('find /usr/share -iname GeoIP.dat') geobase = pygeoip.GeoIP(geopath, pygeoip.MEMORY_CACHE)... (3 Replies)
Discussion started by: metallica1973
3 Replies
Login or Register to Ask a Question