Sunday, November 21, 2010

How can my bash script output Unicode?

Finally I found how to print Unicode characters from a bash script: http://forums.debian.net/viewtopic.php?f=10&t=45394

Here is the code from 'hedgie' that works for me:

for dec in {9472..9599} ; do
    hex=`echo "ibase=10; obase=16; $dec" | bc`
    /usr/bin/printf \\u$hex
done

Tuesday, November 16, 2010

VMware ESX 3 – use lwp-download to grab files

If you need to download an iso file from a ESX 3.x console, you can use the command lwp-download.

First http port must be opened at firewall level:
esxcfg-firewall -o 80,tcp,out,http

Then you can get a file with the command:
lwp-download <url> [<localfilename>]

And finally you should close http port at firewall level:
esxcfg-firewall -c 80,tcp,out,http

VMware ESX 4 – use cURL to grab files

I've found this information by Eric Gray at http://www.vcritical.com/2009/05/vmware-esx-4-use-curl-to-grab-files/

I need to quickly download an ISO image to my new VMware ESX 4 box and discovered that the cURL utility is now included — pretty handy.

If you have not used cURL, it is similar to wget. However, with no parameters cURL will spew the download to standard out — definitely not what you want in the case of an ISO image. Therefore, the -O option — capital O — can be used to save the downloaded file, preserving the filename. If you happen to be behind a proxy server, don’t forget to set the http_proxy environment variable — standard Linux procedure.
[root@cl-168 Storage1]# export http_proxy=http://proxy:3128
[root@cl-168 Storage1]# curl -O http://mirros.easynews.com/linux/ubuntu-releases/hardy/ubuntu-8.04.2-server-amd64.iso
Also you can connect using ftp protocol as follows:

curl -O ftp://myftpsite.com/filename --user myname:mypassword 

Friday, November 5, 2010

Random times in a batch file

You can use random times in a batch file using something like that:

echo randomize >C:\TMP\random.vbs
echo wscript.sleep Int(Rnd * 100000) >>C:\TMP\random.vbs
cscript C:\TMP\random.vbs
dir

Here is a more elaborated example (only for the vbs script):

TopWait=8       'Max. time to wait in hours
randomize
myrand = rnd()
Wait=Int(myrand * 3600 * TopWait)  'Time to wait in seconds

Hours=Wait \ 3600
Minutes=(Wait - (Hours*3600)) \ 60
Seconds=Wait - (Hours*3600) - (Minutes*60)

WScript.Echo "Waiting: " & Wait & " seconds => " & Hours & ":" & Minutes & ":" & Seconds
wscript.sleep Wait * 1000    'Must be in miliseconds
WScript.Echo "Done: " & Wait & " seconds sleeping"

REFERENCES

WScript.Sleep
Suspend the execution of the current script for the specified number of milliseconds.

Syntax
WScript.Sleep lngTime

Arguments:
lngTime is the delay in milliseconds

Example
WScript.Sleep(5000)
WScript.Echo("5 seconds have passed.")

Rnd
Return a random number

Syntax
Rnd[(seed)]

Key
seed A seed value of 0 will return the most recent random number
A seed value > 0 will return the next random number(default)
A seed value < 0 will return the same number

Example
myrand = rnd()
WScript.Echo myrand

Thursday, November 4, 2010

Unattended access to Netscreen devices from vb script


I've found this post at experts-exchange: http://www.experts-exchange.com/Software/Internet_Email/File_Sharing/SSH_Telnet/Q_22920318.html

Here is a VBScript that should do what you are looking for. Just remember your credentials are in plain text in the script, set your permissions accordiningly:

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "C:\putty HOSTNAME -l LOGIN -pw PASSWORD"      ' put putty in C:\
WScript.Sleep 2000
WshShell.AppActivate "HOSTNAME - PuTTY"      'insert correct hostname
WshShell.SendKeys "command"             'insert dns refresh command
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "exit"
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"
You will need to put putty in you C:\ directory or give it an absolute path

Good Luck

Darkstriker69

Google Public DNS

Google has two free DNS servers at 8.8.8.8 and 8.8.4.4 IPs.
http://code.google.com/intl/es-ES/speed/public-dns/

Error connecting to 127.0.0.2 in XP SP2

Symptoms

With Windows XP SP2 some applications which connect to the loop back address range may not function as expected.

Cause
Windows XP SP2 prevents connections to the loop back address range for any address other than 127.0.0.1.

Resolution
Microsoft support has an update available which addresses this issue and is available for downloading at: KB884020

The fix contains the following file info:
13-Aug-2004 22:50 5.1.2600.2505 359,040 Tcpip.sys

This update helps resolve an issue on computers running Windows XP Service Pack 2. Programs that connect to IP addresses in the loopback address range may not work as expected and you may receive an error message indicating you cannot establish a connection. After you install this item, you may have to restart your computer.

Wednesday, November 3, 2010

Cannot Run Executable File Over Network Share On Windows Server

If you have installed the Internet Enhanced Security Configuration you cannot run any executable file from a network share.

To uninstall it you can go to http://www.visualwin.com/IE-enhanced-security/ and follow the instructions to uninstall Internet Explorer Enhanced Security Configuration for non-admin users, reboot, and viola!