Tag Archives: cli

Python – File Searcher

0
Filed under python
Tagged as , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Python script to search file. Tested on Linux.
Usage: python filesearcher.py <TARGET_DIR>

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

from os import walk
from sys import argv

def searching(dir, target):
        status = False
        for rootdir, dirs, files in walk(dir):
                for file in files:
                        if file == target:
                                status = True
                                path = rootdir+"/"
        if status:
                print target, "was found at:", path
        else:
                print target, "not found"

if __name__ == "__main__":
        if len(argv) != 2:
                print "Usage: python filesearcher.py <TARGET_DIR>"
                exit()

        filename = raw_input("target file: ")
        dir_name = argv[1]
        searching(dir_name, filename)



python,logo,banner

Python – Directory Scanner

0
Filed under python
Tagged as , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Python script to scan directory. Tested on Linux.
Usage: python dirscanner.py <YOUR_DIR>

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

from os import walk
from sys import argv

def scanning(dir):
        for rootdir, dirs, files in walk(dir):
                for file in files:
                        print rootdir+"/"+file

if __name__ == "__main__":
        if len(argv) != 2:
                print "Usage: python dirscanner.py <YOUR_DIR>"
                exit()
        dir_name = argv[1]
        scanning(dir_name)



python,logo,banner

Bash – Tweeting

0
Filed under bash
Tagged as , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple bash script to update twitter status. You may need install cURL.
Usage: ./filename.sh “your tweet”

#!/bin/bash
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork@gmail.com

username="YOUR_TWITTER_USERNAME"
password="YOUR_TWITTER_PASSWORD"
tweet=$1

length=`echo $tweet | wc -m`
if [ $length -gt 140 ]; then
        echo "Your tweet is longer than 140 characters"
else
        xml=`curl -k -u $username:$password -d status="$tweet" https://twitter.com/statuses/update.xml`
        echo "$xml"
fi



logo,snippet,badge,pixel badge,bash