I have a server with a php requiring basic authentication, like this:
header('WWW-Authenticate: Basic realm="do auth"');
header('HTTP/1.0 401 Unauthorized');
...?>
And the basic authentication in wget do not worked:
wget --auth-no-challenge --http-user="username" --http-password="password" -O- "http://url"
wget --keep-session-cookies --save-cookies=cookies.txt --load-cookies=cokies.txt --http-user="username" --http-password="password" -O- "http://url"
I always received the 401 Authorization failed.
The saved cookie is always empty.
With my way, I received the header from the server and save the cookie, then resend the session cookie with authentication data
Show Sample Output
useful if you want to get the source code of a in memory function Show Sample Output
Sometimes you want to write the script output to stdout but you need to send it to email.
If you use:
var="$( ls / )";
echo -e "$var";
works but, you need to wait the script terminate to bufferize then print the output var;
With this way, you can use/work/print the output before the variable receive all the output content, then after it you can use the variable for anything else, like send email.
Show Sample Output
Useful to recover a output(stdout and stderr) "disown"ed or "nohup"ep process of other instance of ssh. With the others options the stdout / stderr is intercepted, but only the first n chars. This way we can recover ALL text of stdout or stderr Show Sample Output
usefull for posts via wget Show Sample Output
there's some options, see more details in : wmic /? wmic process /? wmic process list /? Show Sample Output
Sometimes you don't want to leave history, because of passwords use or somethink like. I think it help.
alternative to
curl ifconfig.me
for those that don't have curl
Show Sample Output
specially usefull for sql scripts with insert / update statements, to add a commit command after n statements executed. Show Sample Output
the database client sqlplus generate results one line per row. This function convert the sqlplus output to show the result vertically, in layout: Column_name=[Column_Value]. Very usefull for scripts. Show Sample Output
generates a picture file with the text. Some other samples in: http://www.imagemagick.org/Usage/text/ Show Sample Output
if you, like me, do not have the numsum, this way can do the same. Show Sample Output
the below command create a alias for share your internet connection with another.
ifconfig eth0:1 192.168.0.1/24
Its obviously necessary too activate the iptables post-routing and ip forwarding, as root:
modprobe iptable_nat
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
Be sure that the alias 192.168.0.0/24 is not your active real ip range
A way not so simple but functional for print the command for the process that's listening a specific port.
I got the pid from lsof because I think it's more portable but can be used netstat
netstat -tlnp
Show Sample Output
the sql command lpad and rpad using sed
for lpad, invert the &_ with _&:
ls / | sed -e :a -e 's/^.\{1,15\}$/_$/;ta'
Show Sample Output
the sed way to print a linhe with 50 hyphens
the sed way to print line numbers Show Sample Output
searching for sed to make a csv, I found the solution from Mr. Stolz in http://funarg.nfshost.com/r2/notes/sed-return-comma.html
you can also to use:
tr "\n" "," ;
But I was looking for a sed way =)
Show Sample Output
on this way we can define the body too
There's too many options to number, My curiosity has forced me to make it using only sed. Maybe useful... or not... :-S
In other way of xargs, only with find -exec
in loop, until the last port (65535), list all opened ports on host. in the sample I used localhost, but you can replace with any host to test. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: