Thursday, April 28, 2011

Delete no of day's old file in your backup folder - Windows

This is simple vb script to delete no of day's old files on your windows computer.You can automate this script with windows Task Manager. 

Open notepad and paste following script.

Dim Fso
Dim Directory
Dim Modified
Dim Files
Set Fso = CreateObject(”Scripting.FileSystemObject”)
Set Directory = Fso.GetFolder(”D:\test”)
Set Files = Directory.Files
For Each Modified in Files
If DateDiff(”D”, Modified.DateLastModified, Now) > 7 Then Modified.Delete
Next

D:\test is my test directory. You can change it as your need. 7 is days which you want to delete how many days old files. Save this file as <filename>.vbs.

Get Network Status on Windows

You can use the windows in-built command to check which all computers are connected to your computer through their domain names or ip addresses.

The command is NetStat Stands for Network Status.

Syntax & Available options :

Code:

netstat [-a] [-e] [-n] [-s] [-p protocol] [-r] [interval]

Meaning of each option :

-a Displays all connections and listening ports. Server connections are normally not shown.

-e Displays Ethernet statistics. This may be combined with the -s option.

-n Displays addresses and port numbers in numerical form (rather than attempting name look-ups).

-s Displays per-protocol statistics. By default, statistics are shown for TCP, UDP, ICMP, and IP. The -p option can be used to specify a subset of the default.

-p protocol Shows connections for the protocol specified by protocol; protocol can be tcp or udp. If used with the -s option to display per-protocol statistics, protocol can be tcp, udp, icmp, or ip.

-r Displays the contents of the routing table.

interval Redisplays selected statistics, pausing interval seconds between each display.

Press CTRL+B to stop redisplaying statistics. If this parameter is omitted, netstat prints the current configuration information only once.

Mount ISO Image under Linux

Create the directory where your ISO is going to be mounted:
mkdir /media/ISO

Mount your ISO file:
mount -t iso9660 -o loop image.iso /media/ISO

Mount a Windows share on Linux with Samba

This article describes how to set up a share from a Linux to a Windows. Samba has to be installed.
 
To test if your Linux machine sees the shares on the Windows : 
smbclient -L <windows-box> -U <username> 
 
Make a directoy for the mountpoint: 
mkdir /mnt/<name-of-mount-point> 
 
Mount the share: 
mount -t smbfs -o username=<username>,password=<password> //<win-box>/<share> /mnt/<name-of-mountpoint> Note: The syntax -username=<username>,password=<password> saves the password. 
  
Create a symbolic link to the mounted drive: ln -s /mnt/<name-of-mount-point> /<path-of-symlink>

Samba With Recycle Bin

I'm working under Linux and Windows network long time. Usually we are sharing document with each others with Samba or Windows File Sharing. But the problem is, after delete file on shared document, that file will be deleted permanently. There is no way to restore accidentally deleted files. We have to use recover tools to recover deleted files. But problem is, recover option is not familiar with normal computer users.  If you are using Windows, there are many 3rd party tools that can help you recover your files easily. But if you are using Linux, then it can be quite a huge problem. Following configuration will useful under Linux.
First you need to create the /etc/samba/recycle.conf file.  Login as root.vi /etc/samba/recycle.conf
 
Then edit  recycle.conf file as follow.
##Recycle Bin Configuration File##
name = Recycle Bin
mode = KEEP_DIRECTORIES|VERSIONS|TOUCH
maxsize = 0
exclude = *.tmp|*.temp|*.o|*.obj|~$*|*.~??|*.log|*.trace
excludedir = /tmp|/temp|/cache
noversions = *.doc|*.ppt|*.dat|*.ini

and then edit your /etc/samba/samb.conf file...
sudo vi /etc/samba/smb.conf
 
add the following lines to the each share folder which you'd like the recycle bin to live.
 
vfs object = recycle
config-file = /etc/samba/recycle.conf
recycle:repository = Recycle Bin
recycle:keeptree = Yes
recycle:versions = Yes
 
then restart your samba daemons and the recycle bin should show up after a few momnents (but most likely after you delete your first file).
/etc/init.d/samba restart

Recover Deleted File in Debian

Package : Foremost
Latest Version : foremost-1.5.7
Home Page : http://foremost.sourceforge.net/

Foremost is a console program to recover files based on their headers, footers, and internal data structures. This process is commonly referred to as data carving. Foremost can work on image files, such as those generated by dd, Safeback, Encase, etc, or directly on a drive. The headers and footers can be specified by a configuration file or you can use command line switches to specify built-in file types. These built-in types look at the data structures of a given file format allowing for a more reliable and faster recovery. .

Installation:
Download deb package from http://ftp.us.debian.org/debian/pool/main/f/foremost/foremost_1.5.7-1_i386.deb

wget http://ftp.us.debian.org/debian/pool/main/f/foremost/foremost_1.5.7-1_i386.deb

If there is not wget installed on your Debian computer, first install it.
apt-get install wget

Install debian package
dpkg -i foremost_1.5.7-1_i386.deb

Currently foremost can recover the following file types:
  • jpg – Support for the JFIF and Exif formats including implementations used in modern digital cameras.
  • gif
  • png
  • bmp – Support for windows bmp format.
  • avi
  • exe – Support for Windows PE binaries, will extract DLL and EXE files along with their compile times.
  • mpg – Support for most MPEG files (must begin with 0x000001BA)
  • wav
  • riff – This will extract AVI and RIFF since they use the same file format (RIFF). note faster than running each separately.
  • wmv – Note may also extract -wma files as they have similar format.
  • mov
  • pdf
  • ole – This will grab any file using the OLE file structure. This includes PowerPoint, Word, Excel, Access, and StarWriter
  • doc – Note it is more efficient to run OLE as you get more bang for your buck. If you wish to ignore all other ole files then use this.
  • zip – Note is will extract .jar files as well because they use a similar format. Open Office docs are just zipâd XML files so they are extracted
    as well. These include SXW, SXC, SXI, and SX? for undetermined OpenOffice files.
  • rar
  • htm
  • cpp – C source code detection, note this is primitive and may generate documents other than C code.
.
For add or remove more file types, you can edit /etc/foremost.conf

Foremost Syntax
foremost  [-h][-V][-d][-vqwQT][-b][-o] [-t][-s][-i]
Available Options
-h Show a help screen and exit.
-V Show copyright information and exit.
-d Turn on indirect block detection, this works well for Unix file systems.
-T Time stamp the output directory so you don’t have to delete the output dir when running multiple times.
-v Enables verbose mode. This causes more information regarding the current state of the program to be dis-played on the screen, and is highly recommended.
-q Enables quick mode. In quick mode, only the start of each sector is searched for matching headers. That is,the header is searched only up to the length of the longest header. The rest of the sector, usually about 500 bytes, is ignored. This mode makes foremost run con- siderably faster, but it may cause you to miss files that are embedded in other files. For example, using quick mode you will not be able to find JPEG images embedded in Microsoft Word documents.
Quick mode should not be used when examining NTFS file systems. Because NTFS will store small files inside the Master File Table, these files will be missed during quick mode.
-Q Enables Quiet mode. Most error messages will be sup-pressed.
-w Enables write audit only mode. No files will be extracted.
-a Enables write all headers, perform no error detection in terms of corrupted files.
-b number Allows you to specify the block size used in foremost. This is relevant for file naming and quick searches. The default is 512.
foremost -b 1024 /dev/hda1
-k number Allows you to specify the chunk size used in foremost.This can improve speed if you have enough RAM to fit the image in. It reduces the checking that occurs between chunks of the buffer. For example if you had > 500MB of RAM.
foremost -k 500 /dev/hda1
-i file The file is used as the input file. If no input file is specified or the input file cannot be read then stdin is used.
-o directory Recovered files are written to the directory directory.
-c file Sets the configuration file to use. If none is speci-fied, the file “foremost.conf” from the current directory is used, if that doesn’t exist then “/etc/fore-most.conf” is used. The format for the configuration file is described in the default configuration file included with this program.
-s number Skips number blocks in the input file before beginning the search for headers.
foremost -s 512 -t jpeg -i /dev/hda1

Examples:
Search for jpeg format skipping the first 100 blocks
foremost -s 100 -t jpg -i /dev/hda1
  
Only generate an audit file, and print to the screen (verbose mode)
foremost -av /dev/hda1 
 
Search all defined types
foremost -t all -i /dev/hda1 
 
Search for gif and pdf
foremost -t gif,pdf -i /dev/hda1 
Search for office documents and jpeg files in a Unix file sys-tem in verbose mode.
foremost -v -t ole,jpeg -i /dev/hda1 
Run the default case
foremost /dev/hda1
 
* /dev/hda1 is your hard disk mount point 
** I'm no guarantee that foremost will succeed in recovering your files, but at least there’s a chance. 

Wednesday, April 27, 2011

SQL Developer -3.0.04.34 Timezone Error connecting to Oracle 10g Database

Open the sqldeveloper.conf file in your oracle home sql developer directory:
<Drive>:\<ORACLE_HOME>\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf

and add the line

Add VMOption -Duser.timezone=<TIME ZONE>


Ex: AddVMOption -Duser.timezone=EST

Save file, close Sql Developre and reopen.

If you got this message on Oracle JDeveloper

Find jdev.conf file on jdeveloper\jdev\bin\
Add above line to end of file and save.

Restart your JDeveloper application.