ejes consulting

Techincal Consulting Design and Automation

Archive for the ‘Scripts’ Category

More Command Line Magic

leave a comment »

Wow, I was looking around for a way to quickly convert my ls -al listing into octal ’0774′ permission display. I found a really neat awk script that does just this here:
http://www.linuxforums.org/forum/newbie/21722-command-shows-me-permissions-file-octal.html#post371256

it’s this:
ls -l | awk ‘{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(“%0o “,k);print}’

to make it permanent, add this to your .profile:
alias l=”ls -la –color | awk ‘{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\” %0o \”,k);print}’”

Written by ejes

February 25, 2011 at 11:11 pm

Posted in Hacking, Programming, Scripts

Tagged with ,

Amazing One Line Script

leave a comment »

I was stumbling around on the internet this morning and I found this awesome site… (http://www.centerkey.com/tree/)

This guy posted an amazing one line script that will graphically show your directory tree with a simple one line command:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'

and that’s all!!! It works great!

Written by ejes

March 17, 2010 at 11:42 am

Tutorial: Protect Folders In Windows

leave a comment »

Sometimes we have folders and files that we don’t want anyone to be able to read… banking information, taxes, porn, lots of things.

I was thinking of this, when I decided to peek around the web to find anything that may help; and although i forget the site, i DID find something quite handy. (http://www.bukisa.com/articles/108657_remove-stored-passwords-and-hide-floder-with-recycle-bin)

Basically, it turns any named folder into the “recycle bin” by using the CLSID of the recycle bin.  Interesting Stuff!

Like normal, I created a batch script for those of you interested.(http://ejesconsulting.wordpress.com/scripts/hidefolder-bat/)

Written by ejes

July 27, 2009 at 7:33 am

Posted in Hacking, Scripts

Bug: Visual Basic Scripting

leave a comment »

I was developing a source code repository with revision tracking system in VBS for a client.

In this repository each revision would be incremented by 0.01 on each commit to the repository.

Kind of like CVS but much, much simpler.

So it turned out to be quite simple (the source is in my Scripts Library) but I found some strange activity in VBS when it comes to floating point math.

VBS has a function to convert a signed decimal string to a number so that you can perform mathematical functions on it.  “CSng(string)”  is the function.

So once you’ve converted a number from a string, then add 0.01 it should effectively add 0.01 to the last number.

So, lets consider this code:

Version=CSng("0.01")
WScript.Echo Version
Version=Version+0.01
WScript.Echo Version

What would you assume the ouput would be?  0.02 right?vbs-csgn error

WRONG!  VBS outputs “1.99999997764826E-02″.

VBS Can’t Do Math!

Written by ejes

June 15, 2009 at 11:16 am

Follow

Get every new post delivered to your Inbox.