#!/bin/bash
DIRECTORY=/home/test
find $DIRECTORY -name "* *"|while read fname;do
new_name=`echo $fname | tr " " "_"`
if [ -e $new_name ];then
echo "Exists"
else
mv "$fname" $new_name
fi
done
20.02.2016 г.
31.12.2015 г.
Python run TeamViewer from ini file.
#---------------Import Modules-------------------
import subprocess, platform, os, ConfigParser, time
from Tkinter import *
from tkFileDialog import askopenfilename
#---------------Tkinter-------------------------
root = Tk()
root.title("TeamViewer_Parse_From_File")
root.geometry("300x550")
#Scrol bar settings
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )
#-------------Global Variable is here------------------
List_with_Server = []
Config = ConfigParser.ConfigParser()
Path = None
Path_To_Ini = None
Run = "TeamViewer.exe"
#--------------Check machine 86 or 64------------------
if platform.machine() == 'x86':
#global name
Path = "C:\\Program Files\\TeamViewer"
Path_To_Ini = "C:\\Program Files\\TeamViewer\\acc.ini"
else:
#global name
Path = "C:\\Program Files (x86)\\TeamViewer"
Path_To_Ini = "C:\\Program Files (x86)\\TeamViewer\\acc.ini"
#--------------Function is here------------------------
#--------------Load servers from file in windows-------
def Popalni():
global Path_To_Ini
global Path
global Run
global Config
global List_with_Server
os.chdir(Path)
ini_file = open(Path_To_Ini, 'r')
ini_file_content = ini_file.read().strip()
Config.read(Path_To_Ini)
List_with_Server = list(Config.sections())
for i in (Config.sections()):
mylist.insert(END,i)
mylist.see(END)
mylist.update()
def Open_Directory():
"""Use for add additional file"""
name = askopenfilename()
subprocess.Popen(["notepad.exe", name])
#----------After click on server name load param to begin---
def choose():
firstIndex = mylist.curselection()[0]
global Choiced_Name
global Config
Choiced_Name = List_with_Server[firstIndex]
option = Config.options(Choiced_Name)
ID_Server = Config.get(Choiced_Name, "User")
Password_Server = Config.get(Choiced_Name, "Password")
p = subprocess.Popen(Run+" -i " + ID_Server + " --Password " + Password_Server, shell=True)
time.sleep(2)
p.kill()
root.destroy()
#Menu Bar settings
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Load_All", command=Popalni)
filemenu.add_command(label="Open_Ini_File", command=Open_Directory)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="Menu", menu=filemenu)
root.config(menu=menubar)
mylist = Listbox(root, yscrollcommand = scrollbar.set , bg="lightblue")
frame=Frame(root)
frame.pack()
#Label(text="Anchor").pack(side=LEFT)
chooseButton = Button(frame, text="Load_List", command=Popalni ,bg="lightgreen")
chooseButton.pack(side=LEFT,anchor=NW)
chooseButton1 = Button(frame, text="Run_ID", command=lambda:choose(), bg="lightgreen")
chooseButton1.pack(anchor=NW)
mylist.pack( side = LEFT, fill = BOTH, expand=1 )
scrollbar.config( command = mylist.yview )
#-----------------Take the magic--------------------
if __name__ == "__main__":
mainloop()
The ini file called "acc.ini" is in the following form:
[First_Id]
User=111111111
Password=Password
[Second_ID]
User=222222222
Password=Password
11.12.2015 г.
How to wathc and listen movie and mp3 from another machine
Install virtual mashine or not you are choice:
install samba server
apt-get isntall samba
#config of samba share and add to the end of file /etc/samba/smb.conf
[share]
comment = Borko share
path = /home/borko/share
valid users = borko
read only = no
writables = yes
gueest ok = no
On mashine where put file and connect to mashine install samba-client
To mount server use
mount -t cifs //ip/share-filder -o username=borko,password=wonderwand /tmp
If you use local network use mount if you whant to put file in other segment use ftp or another.
To downoad torrent file make use aria
get toorent file and add this in terminal:
aria2c http://zamunda.net/download.php/444449/torrent-name.torrent
In the same folder (may use ssh) start daemon:
python -m SimpleHTTPServer
In your broweser put ip from server and port 8000(default)
Watch movie or listen mp3 from your browser.
install samba server
apt-get isntall samba
#config of samba share and add to the end of file /etc/samba/smb.conf
[share]
comment = Borko share
path = /home/borko/share
valid users = borko
read only = no
writables = yes
gueest ok = no
On mashine where put file and connect to mashine install samba-client
To mount server use
mount -t cifs //ip/share-filder -o username=borko,password=wonderwand /tmp
If you use local network use mount if you whant to put file in other segment use ftp or another.
To downoad torrent file make use aria
get toorent file and add this in terminal:
aria2c http://zamunda.net/download.php/444449/torrent-name.torrent
In the same folder (may use ssh) start daemon:
python -m SimpleHTTPServer
In your broweser put ip from server and port 8000(default)
Watch movie or listen mp3 from your browser.
5.10.2015 г.
Debian grub2 and RAID1 degraided
dpkg-reconfigure grub-pc
cd /etc/initramfs-tools/scripts/local-top
cp /usr/share/initramfs-tools/scripts/local-top/mdadm .
Replace
log_failure_msg "failed to assemble all arrays."
With this
log_warning_msg "failed to assemble all arrays...attempting individual starts" for dev in $(cat /proc/mdstat | grep md | cut -d ' ' -f 1); do log_begin_msg "attempting mdadm --run $dev" if $MDADM --run $dev; then verbose && log_success_msg "started $dev" else log_failure_msg "failed to start $dev" fi done
At the end run this
update-initramfs -u
cd /etc/initramfs-tools/scripts/local-top
cp /usr/share/initramfs-tools/scripts/local-top/mdadm .
Replace
log_failure_msg "failed to assemble all arrays."
With this
log_warning_msg "failed to assemble all arrays...attempting individual starts" for dev in $(cat /proc/mdstat | grep md | cut -d ' ' -f 1); do log_begin_msg "attempting mdadm --run $dev" if $MDADM --run $dev; then verbose && log_success_msg "started $dev" else log_failure_msg "failed to start $dev" fi done
At the end run this
update-initramfs -u
3.09.2015 г.
Python copy folder from USB to map drive in windows machine
#! --*-- coding:utf-8 --*--
###################################
# Uses for copy folder from, #
# USB drive to map used device #
# #
# Do not edit by hand #
###################################
#Imort requeare module's
import os,subprocess,shutil,time,sys
#General param is here
remote_ip = 'ip' #ip for server
remote_share_folder = 'share' #share folder from server
remote_user = 'Administrator' #Username for server
remote_pass = 'pass' #password name for server
local_folder = r'c:\test' #local folder where looking for dirname
mapping_char = 'G:' #charackter for maping
date_now = str(time.ctime()).split()[2]+str(time.ctime()).split()[1]+str(time.ctime()).split()[-1]
#--------------------Begin Function ----------------------------------#
#first function
def copyDirectory(src, dest):
"""
used shutil.copytree for copy from src to dest
if have somthing wrong like folder exists copy stop
and script close
"""
try:
shutil.copytree(src, dest)
print "Success Copied folder!"
#print (src,dest)
# Directories are the same
except:
print "Somthing wrong with copy Bye!"
sys.exit(1)
#second function
def clear_folder(local_folder):
"""
rmtree delete folder even folder is not empty
then makedirs recovers folder
"""
shutil.rmtree(local_folder)
os.makedirs(local_folder)
#third function
def list_usb_flash():
"""
chdir use to goto in usb drive, then list drive for file
for eny file give full path and parse to first function
finaly up one step and begin second function
"""
os.chdir(local_folder)
for root,dirname,filename in os.walk(local_folder):
for f in dirname:
fol = os.path.join(root,f)
copyDirectory(fol, (mapping_char+'\\'+f+"-"+date_now))
os.chdir(r'c:\\')
clear_folder(local_folder)
#---------------End function's------------------------------------------#
if os.path.isdir(local_folder):
print "Folder exists now begin..."
if os.path.isdir(mapping_char):
list_usb_flash()
else:
maping = subprocess.Popen('net use %s \\\\%s\%s /user:%s %s' % (mapping_char,remote_ip,remote_share_folder,remote_user,remote_pass),shell=True, stdout=subprocess.PIPE)
list_usb_flash()
else:
print "USB Driver maybe not mounted!!!"
.
Абонамент за:
Публикации
(
Atom
)