Networking
Batch Rename numbered files in DOS
by nevermore on Jun.07, 2011, under Networking, Windows, geeky, work
Well, today my boss “forgot” how to batch rename files in dos. He had a bunch of numbered jpg images like 001.jpg and 002.jpg and needed them renamed to 301.jpg and 302.jpg etc etc. He is an “engineer” from romania
and i quote “When I used to do it, it was much simpler, such as C:\copy *.jpg 100+*.jpg or similar.” Now I’ve been using DOS since 6.22 and to my knowledge copy has NEVER worked like that. Of course i cant just call my boss out so i linked him to some yahoo answers page about how to do it. Being an “engineer” i figured he could READ the page and figure out how to modify the script to suit his needs. He then emails me back and says “Please use the info below and tell me what I need to enter”. LOL. Great. Why cant you just fucking use TotalCommander or some other Windows Commander style application that has a built in rename function?? Or download one of the 100′s of shareware/freeware renamer programs. You DO have antivirus right? Or did you not keep it updated like i told you to? /rant
So anyway, i did it, here it is:
@echo off
SETLOCAL EnableDelayedExpansion
for /f "tokens=1-2 delims=." %%i in ('dir /b *.jpg') do (
SET /A var=%%i+300
copy %%i.%%j !var!.%%j
)
All the script does is a for loop in which it runs a “dir” command and takes the filename (%%i) and adds 300 since the files are numeric and /A means use arithmetic. Then it issues a copy command to make a new copy of the file now with the new number.
Couple things i had forgot about writing dos bat files:
1. While in Cmd all your variables work with a single % but when running the .bat file you have to use 2 ie: %%i otherwise they wont work
2. if you SET a variable and need to call it later %var% doesnt work! you must use !var!
And btw, wtf Microsoft. Why is there no fucking batch rename tool built into windows? Dont you think that might be a handy feature for anyone that has a digital camera? Thats nice you can shout at your Kinect and it will play a youtube or netflix video, but some of us need to do work with computer still and having the OS actually have these types of features that should have been implemented a decade ago might be handy.
Quick and Easy way to mass detached all user databases in Microsoft SQL
by nevermore on Jun.23, 2009, under Networking, SQL Administration, work
So, i was cleaning up my “test server” and wanted to detach all the databases i had currently attached in MS SQL. Assuming you installed everything to their default locations this is all you should need to do in order to mass detach all the user db’s.
1. Install SSEUtil from here i recommend extracting it to c:\windows\system32 so you can run it from anywhere in the command line.
2. Run the following command:
sseutil -m -s localhost -user sa -pwd? -detach "C:\Program Files\Microsoft SQL Server\MSSQL\Data\*"
You should see output similar to the following:
Detached 'mydb1' successfully.
Detached 'mydb2' successfully.
Detached 'mydb3' successfully.
You can of course update localhost so that you can do this remotely and of course you can change the user.
SSEUtils has some other cool features as well for mass re-attaching.
anyway, more workieeeee for me before i head out to Matisyahu tonight.
laters
g-fiz
Setting up VPN on a Cisco ASA5500 series
by nevermore on Jul.25, 2008, under Networking, work
So, im pretty new to this whole cisco equipment stuff but man is it cool. I took over the net admin position at this company as the last guy left and was pretty much worthless anyway or so everyone around here seems to say and they were right in the middle of a network upgrade that had been going on for over a year and a half lol….yeah….stupid.
Anyway, they bought a Cisco ASA5510 to be their new firewall however, they are currently using microsoft ISA to route traffic to the webservers as a reverse proxy and the ASA series of course do not offer this feature. So the thing has been sitting around since i started working here without power at all and in the last month ive figured out all our network setting which were not documented anywhere of course, and configured both the inside and outside adapters and after some help from my friend david had my static route setup and everything was good. I could get out from the inside to the interwebs without issue. Sweet! Alright, now on to VPN cuz eventually we’re going to need it for access to the webservers which im going to setup in a DMZ.
So i run through the VPN wizard in the ASDM 6.1 software. Oh btw, i updated the asa firmware and asdm too. That was easy. All i did was install a tftp server on a machine i had access to that had an internet ip and then issued the following commands:
ASA5510# copy tftp disk0
Address or name of remote host []? ipgoeshere
Source filename []? asa803-k8.bin
Destination filename [disk0]? disk0:asa803-k8.bin
Accessing tftp://ipgoeshere/asa802-k8.bin...!!!!!! x 290731982471
Writing file disk0:/asa802-k8.bin... !!!!! x 9274918274182974
14524416 bytes copied in 118.210 secs (123088 bytes/sec)
I did the same thing for the ASDM-611.bin as well.
Anyway, back to the VPN. So i run the wizard and setup the remote access pool and group and add a user and set it to the internet interface for “where connections are comming from” and clicked finished and then went to try and connect and i was able to connect but couldnt see any other hosts or even connect via IP address.
I then started reading about common Cisco VPN issues and i found the article on this page:
http://www.cisco.com/en/US/products/ps6120/products_tech_note09186a00807e0aca.shtml#topic1
reading through it the first thing i found was:
Problem – An IPsec VPN Configuration Does Not Work
A recently configured or modified IPsec VPN solution does not work.
A current IPsec VPN configuration no longer works.
Solutions
This section contains solutions to the most common IPsec VPN problems. Although they are not listed in any particular order, these solutions can be used as a checklist of items to verify or try before you engage in in-depth troubleshooting and call the TAC. All of these solutions come directly from TAC service requests and have resolved numerous customer issues.
Note: Some of the commands in these sections have been brought down to a second line due to spatial considerations.
Enable NAT-Traversal (#1 RA VPN Issue)
NAT-Traversal or NAT-T allows VPN traffic to pass through NAT or PAT devices, such as a Linksys SOHO router. If NAT-T is not enabled, VPN Client users often appear to connect to the PIX or ASA without a problem, but they are unable to access the internal network behind the security appliance.
If you do not enable the NAT-T in the NAT/PAT Device, you can receive the regular translation creation failed for protocol 50 src inside:10.0.1.26 dst outside:10.9.69.4 error message in the PIX/ASA.
Similarly, if you are unable to do simultaneous login from the same IP address, the Secure VPN connection terminated locally by client. Reason 412: The remote peer is no longer responding. error message appears. Enable NAT-T in the head end VPN device in order to resolve this error.
Note: With Cisco IOS Software Release 12.2(13)T and later, NAT-T is enabled by default in Cisco IOS.
Here is the command to enable NAT-T on a Cisco Security Appliance. The 20 in this example is the keepalive time (default).
PIX/ASA 7.1 and earlier
pix(config)#isakmp nat-traversal 20
PIX/ASA 7.2(1) and later
securityappliance(config)#crypto isakmp nat-traversal 20
The clients need to be modified as well in order for it to work.
In Cisco VPN Client, choose to Connection Entries and click Modify. It opens a new window where you have to choose the Transport tab. Under this tab, choose Enable Transparent Tunneling and the IPSec over UDP ( NAT / PAT ) radio button. Then click Save and test the connection.
So i did exactly that through the CLI on the ASA5500 and connected again and OMG i can RDP into other machines on the network through VPN either by hostname or IP and i can map network drives too which is good. Now i just gotta setup the DMZ and a new reverse proxy (cough nginx cough)
Upgrading from 1 T1 to 3 Bonded T1's
by nevermore on Jul.16, 2008, under Networking, work
At work we have been going through an upgrade of our internet connection from 1 T1 to 3 Bonded T1′s and yesterday, finally, we got the 2 new T1′s linked and installed. Pretty cool how its done actually, and being a newb i never knew that T1′s are just specially wired cat5 cable with RJ45′s end wired to be a T1 instead of a network cable.
In order to get it working, we had our local phone company Qwest come out to run the connections to the CO and into the westel T1 card where it gets converted to an RJ45 jack. From there in our building we have a lower phone riser and an upper one, so the T1′s go into the lower riser and then get reconnected upstairs. Now instead of having 1 T1 line coming out of the wall we have 3 which go into a Nortel SR1004 where the 3 T1′s are then bundled into 1 “connection” and then into our domain controller.
I just ran a speedtest from www.speedtest.net as im typing this and here are the results:

Anyway, all is good now here cept for the installer came back this morning to pick up some equipment they left behind and we no longer needed and now the entire phone system is no longer working. They are back out here now fixing it, but always good for a new laugh
WinSCP, installing a WP theme and SUDO of doom
by nevermore on Jul.06, 2008, under Networking
So, i got this silly little wordpress blog thing installed and i was instructed to document just about whatever i did, so here i go.
Of course i didnt want to stare at the default theme so i went and found one i wanted and i happen to be on a windows box so i tried to use WinSCP to transfer the files into the themes folder of my wordpress install and i got a big fat error telling me that PERMISSION IS DENIED or something to that effect. Elderec, knowing more about me says just go here and do this and that and blah blah. So i try…fail…and then he goes to edit the /etc/sudoers list and next thing you know sudo is just straight broken. He goes back and fixes what he did but by then my cohort Elderec suggested i just copy the theme to a folder in my home dir and then symlink the folder. Good damn idea! Made a new folder called wordpress themes in my /home/nevermore dir and then browsed to the themes folder and used the following command to symlink the file:
ln -s /path/to/theme/darkwater-11 /wpinstall/wp-content/themes/darkwater-11
Then went into the admin control and omfg j35u5….the theme was installed like whoa.
oh and i just did the same with the wordpress openid plugin