Iam working on a project which connect between a remote and pull files and do some work with these files.While pulling the files there are several directories in the remote,so pulling each folder is time taking.So is there any command which can be used in the script written below so it can automatically pull all files in the folders.
ssh [email protected] 'ls SomeFolder/SomeSubFolder' > folders.txt
echo "Enter the folder name "
scp -r [email protected]:SomeFolder/SomeSubFolder/$folder_name/ $folder_name/
while IFS= read -r -d '' file; do
# single filename is in $file
python scanner_new.py /home/nsadmin/Kiran/bash_script_run_files/"$file"
done < <(find "$folder_name" -type f -print0)
rm -rf $folder_name
python scanner.py $file_name
You could parse the txt file with Python :
from os import path def do_stuff_with_folder(folder_name): folder_name = folder_name.strip() script_name = path.join("/home/nsadmin/Kiran/bash_script_run_files/", folder_name) if path.exists(folder_name): print "Do stuff with folder %s" % folder_name # do stuff with folder_name here else: print "Warning : %s not here" % folder_name with open('folders.txt') as folder_names: for folder_name in folder_names: do_stuff_with_folder(folder_name)
The loop is now inside Python, you'd just need to call the above script :