This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/1392768/rename-part-of-filename | |
rename 's/201402/201404/' 201402* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PORT SCANNING | |
It may be useful to know which ports are open and running services on a target machine. The -z flag can be used to tell nc to report open ports, rather than initiate a connection. Usually it's useful to turn on verbose output to stderr by use this | |
option in conjunction with -v option. | |
For example: | |
$ nc -zv host.example.com 20-30 | |
Connection to host.example.com 22 port [tcp/ssh] succeeded! | |
Connection to host.example.com 25 port [tcp/smtp] succeeded! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TALKING TO SERVERS | |
It is sometimes useful to talk to servers “by hand” rather than through a user interface. It can aid in troubleshooting, when it might be necessary to verify what data a server is sending in response to commands issued by the client. For example, to | |
retrieve the home page of a web site: | |
$ printf "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80 | |
Note that this also displays the headers sent by the web server. They can be filtered, using a tool such as sed(1), if necessary. | |
More complicated examples can be built up when the user knows the format of requests required by the server. As another example, an email may be submitted to an SMTP server using: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATA TRANSFER | |
The example in the previous section can be expanded to build a basic data transfer model. Any information input into one end of the connection will be output to the other end, and input and output can be easily captured in order to emulate file trans‐ | |
fer. | |
Start by using nc to listen on a specific port, with output captured into a file: | |
$ nc -l 1234 > filename.out | |
Using a second machine, connect to the listening nc process, feeding it the file which is to be transferred: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLIENT/SERVER MODEL | |
It is quite simple to build a very basic client/server model using nc. On one console, start nc listening on a specific port for a connection. For example: | |
$ nc -l 1234 | |
nc is now listening on port 1234 for a connection. On a second console (or a second machine), connect to the machine and port being listened on: | |
$ nc 127.0.0.1 1234 | |
There should now be a connection between the ports. Anything typed at the second console will be concatenated to the first, and vice-versa. After the connection has been set up, nc does not really care which side is being used as a ‘server’ and which |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ctrl+Alt+F1, log on | |
unity &> /dev/null & disown | |
or (unity is a compiz plugin) | |
compiz --replace &> /dev/null & disown | |
http://askubuntu.com/questions/38579/how-do-i-restart-an-unity-session-from-the-terminal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/2709458/bash-script-to-replace-spaces-in-file-names | |
find ./tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one or more | |
contributor license agreements. See the NOTICE file distributed with | |
this work for additional information regarding copyright ownership. | |
The ASF licenses this file to You under the Apache License, Version 2.0 | |
(the "License"); you may not use this file except in compliance with | |
the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh user@host tail -F /usr/share/tomcat/logs/catalina.out >> /tmp/host-catalina.out | |
vi ~/.swatchrc: | |
watchfor /"from"/ | |
pipe 'cut -f5- -d" "|python -mjson.tool' | |
swatch -c ~/.swatchrc -t /tmp/host-catalina.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='net.sourceforge.nekohtml', module='nekohtml', version='1.9.18') | |
import org.cyberneko.html.parsers.SAXParser | |
def download(address) | |
{ | |
def file = new FileOutputStream(address.tokenize("/")[-1]) | |
def out = new BufferedOutputStream(file) | |
out << new URL(address).openStream() | |
out.close() | |
} |