in my new job i’ve been tasked with something ugly. webifying a windows CLI command. in my venture to find a way for PHP to spawn an interactive shell I came across this site: CommandWindows.Com.
Yes, yes, yes… windows sucks and we all know it(this is a very good blog post, highly recommend reading it!).
It turn’s out good’ol sysinternals made psexec.exe with the purpose of spawning CLI commands that require interactive console(eg. Platform LSF tools).
Put this one in the books for some way back memory I hope to never need in the future.
They certainly can come in handy though if you don’t want to do some basic grep/awk work.
little example:
$ foo="my words"
$ echo ${foo#my}
words
$ echo ${foo:1}
y words
$ echo ${foo:2}
words
$ echo ${foo:3}
words
$ echo ${foo:4}
ords
$ echo ${foo:1:2}
y
$ echo ${foo:1:3}
y w
$ echo ${foo:1:4}
y wo
$ echo ${foo:1:5}
y wor
$ echo ${foo:1:6}
y word
$ echo ${foo:2:6}
words
$ echo ${foo:3:6}
Category: python, sysadmin /
Tags: no tag / Comments Off
insert
import pdb; pdb.set_trace()
in to area of code area you would like to debug then run script.
These commands allow you to step through the code from the point of where pdb.set_trace() is placed in your script.
p
start with this script.
#!/bin/env python
import pdb
var_0 = 'day'
var_1 = 'night'
print ' var_0: %s\n var_1: %s' % (var_0, var_1)
#pdb.set_trace()
print 'from %s in to %s and back again.' % (var_0, var_1)
run it with the pdb line commented and you get this.
$ ./day.py
var_0: day
var_1: night
from day in to night and back again.
Now uncomment the pdb line and run it again.
$ ./day.py
var_0: day
var_1: night
> /home/msnow/bin/day.py(10)()
-> print 'from %s in to %s and back again.' % (var_0, var_1)
(Pdb) n
from day in to night and back again.
--Return--
> /home/msnow/bin/day.py(10)()->None
-> print 'from %s in to %s and back again.' % (var_0, var_1)
(Pdb) n
$
This shows you part of the program running, then dropping in to the debugger just before the area of code you want to look at.
Now we will change the values assigned to val_0 and val_1 withough editing the file.
$ ./day.py
var_0: day
var_1: night
> /home/msnow/bin/day.py(10)()
-> print 'from %s in to %s and back again.' % (var_0, var_1)
(Pdb) var_0
'day'
(Pdb) var_1
'night'
(Pdb) var_0 = 'morning'
(Pdb) var_1 = 'evening'
(Pdb) n
from morning in to evening and back again.
--Return--
> /home/msnow/bin/day.py(10)()->None
-> print 'from %s in to %s and back again.' % (var_0, var_1)
(Pdb) n
$
i’ve been learning bits of python here and there for work and for play and I came across a simple solution to a simple problem I had to solve in python.
There are some things in python that once you realize how things work you think “that is so simple!”. I had one of those moments.
This particular solution came up when the need to compare user disk quotas arose on different filers.
Category: sysadmin, ubuntu /
Tags: no tag / Comments Off
One of the features I’ve seen on network cards for as long as I can remember is Wake On LAN. I’ve known what the feature is and how it works in principal but never taken the time to set it up.
Yesterday I took the time to google around and came across This How-To on one of my favorite OpenBSD info sites, Calomel.org.
I setup a cron job on my OpenBSD router to wake up my Ubuntu box in the living room at 5:30pm, and another cron job on the Ubuntu box to poweroff at midnight.
Now i’ll waste just a bit less power in my home. Now if only I could get my electric bill below 1000kWh per month…
I had been running the 180 nvidia drivers from another PPA a while then vdpau stopped working, turns out the PPA moved here.
Add these two lines to your /etc/apt/sources.list, then apt-get remove mplayer && aopt-get install mplayer
deb http://ppa.launchpad.net/nvidia-vdpau/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/nvidia-vdpau/ppa/ubuntu karmic main
And if you want to setup a Squeezebox server…
## SlimDevices Squeeze box
deb http://debian.slimdevices.com testing main
I always forgot the procedure for mysql pw recovery so i’m posting it to my blog.
This is a re-post from DebianAdmin.com.
By default, MySQL Server will be installed with root superuser without any password. You can connect to MySQL server as root without requiring password or by keying in blank password. However, if you have set the password for root and forget or unable to recall the password, then you will need to reset the root password for MySQL.
Login as root to the Unix-like (Unix, Linux or BSD) machine with the MySQL server.
Stop the MySQL server by using either of the following command
#/etc/init.d/mysql stop
Now you need to Start MySQL server without password
# mysqld_safe --skip-grant-tables &
Connect to mysql server using mysql client with the following command
# mysql -u root
Now you should be having mysql prompt
mysql>
Now you need to Setup new MySQL root user password
mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where user=’root’;
mysql> flush privileges;
mysql> quit
Note: Replace newrootpassword with the new root password for MySQL server. Flush Privileges is needed to making the password change effect immediately.
Now you need to Stop MySQL Server using the following command
# /etc/init.d/mysql stop
Test Your New Mysql root password
First you need to start mysql server using the following command
# /etc/init.d/mysql start
# mysql -u root -p
Now it will prompt for root password and enter your new root password
my buddy Josh whom I am now working with at Xilinx sent me this. it is the ultimate configuration for one of my favorite time saving apps, screen.
cat ~/.screenrc
vbell off
#
# Change this to the character you wish to use with ctrl instead of 'A'
#
# i.e. escape "``" means ctrl-` `
# escape ^zz
scrollback 10000
hardstatus alwayslastline
hardstatus string '%{= kG}%-Lw%{= KW}%50>%n%f* %t%{= kG}%+Lw%<'
Just doing some friendly nmap scans on an internal network and found this.
Interesting ports on 192.168.200.253:
Not shown: 995 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
5120/tcp open unknown
5555/tcp open freeciv
MAC Address: 00:14:4F:8D:30:7C (Sun Microsystems)
Thought that was kinda funny to have on an X4540 ILOM.