Pages

Wednesday, May 8, 2013

Perl Error: readdir() attempted on invalid dirhandle

Q. I am seeing "readdir() attempted on invalid dirhandle DIR at" error when attempting to open a directory using readdir function in Perl. How can I resolve this?

The error "readdir() attempted on invalid dirhandle DIR at" clearly states that PERL was unable to open directory by using readdir function. There are number of situations which causes this error

1)Check if user who executed perl script have permissions on that directory or not. User should have read permissions to open a directory in Perl. Check permissions by using ls command.

2)Check if directory exists or not? Sometimes users will forgot to check if directory exists or not before opening a directory. To avoid this we can use below code to check before opening a directory.



opendir DIR, $SRCDIR || die ("Can not open dir $SRCDIR");


Keep this line before readdir function so that it will give you a meaningful error message before reading a directory.

3) Are you reading an input from user? Then make sure that your variable which contain directory name should not contain newline character. So use chop or chomp function to remove last character.

chop($DIR=<>)

This will chop of last character.

Hope this helps someone when dealing with open directory in perl.

Tuesday, May 7, 2013

Solution for: mv: cannot move `' to a subdirectory of itself,

Q. How can I move all my files in my working directory to a sub-directory with the working directory? I am getting error "mv: cannot move `' to a subdirectory of itself," Can I move all the files/folder to sub-directory with out this error?

Yes, you can move all your files/folders present in your directory to a sub-directory with out getting that error. This error will occure when mv command try to move this sub-directory as well which it can not do and throws this error. All you have to do set shopt extglop option and try below command

shopt -s extglob
mv !(subdir) subdir/

Know more about shopt here.

Thats it, you will not see the error as shown above. hope this helps some one.

Thursday, May 2, 2013

isohybrid: Warning: more than 1024 cylinders: isohybrid: Not all BIOSes will be able to boot this devic

Q. I am facing issue "isohybrid: Warning: more than 1024 cylinders:  isohybrid: Not all BIOSes will be able to boot this devic", How can I resolve this?

First this is not an issue or error. This is just a warning not an error and it is just a warnning. This warning will be displayed when you are trying to convert a normal ISO file to hybrid ISO file by using isohybrid command

isohybrid /path/to/normal/iso/file

This error will come when your ISO file is more than 1GB size.

Wednesday, February 27, 2013

error: Requested operation is not valid: Disk does not support snapshotting

error: Requested operation is not valid: Disk  does not support snapshot

This error arises when you try to take a snapshot of a VM hard disk with virsh command
as shown below


virsh snapshot-create Clusterbase

error: Requested operation is not valid: Disk '/path/to/kvm/clusterbase.img' does not support snapshot.

If you see image of this VM is .img format, by default Virsh snapshot will work only for qcow2 format as of time of this post writing. So first convert that image to qcow2 format and then try to do a snapshot t with same command.

Convert img file to  qcow2 format


qemu-img convert -f raw -O qcow2 /path/to/kvm/clusterbase.img /path/to/kvm/clusterbase.qcow2

Hope this helps to resolve this error.

Sunday, February 24, 2013

Loaded plugins:fastest mirror Loading mirror speed from cached hosfile Setting up install process Nothing to do

Q. I am seeing below error when installing some packages


 Loaded plugins:fastest mirror
  Loading mirror speed from cached hosfile
  Setting up install process
  Nothing to do

This error will come when you execute below command

yum install somepackage

and the repo is set with "enable=0", try to change it or use --enablerepo= as shown below.

yum --enablerepo=yourreponame install somepackage


If you set enable=0 that indicates that dont include this repo when installing RPM packages. And enable=1 will include this repo when installing packages.

Hope this helps some one.

Friday, February 22, 2013

error: command 'save' requires option

This error will come when you are trying to save VM using virsh command. When you try to save VM status using Virt-manager we no need to mention any file to save the status. Virt-manager will take care of saving it. But virsh have no mechanism like this. We have to provide a file to save the machine status.

virsh save domaname filename

Example
virsh save linux1 /opt/linux1.stat

Thursday, January 17, 2013

Failed to mount ': Input/output error NTFS is either inconsistent, or there is a hardware fault, or it's a SoftRAID/FakeRAID hardware.

Q. I am getting following error when I mounted my external HDD in Ubuntu Linux and getting below error.



root@linuxnix.com:~# mount -t ntfs /dev/sde1 /mnt
$MFTMirr does not match $MFT (record 0).
Failed to mount '/dev/sde1': Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it's a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation
for more details.

This error usually occurs
  • When computer shutdown/restarted/suspended/hibernated
  • Not properly mounted etc.
To fix this issue you have to install ntfsprogs which will provide fixing of 

As a root run below command

apt-get install ntfsprogs

Fixing by using ntfsfix as root

ntfsfix /dev/sde1

Once this is fixed you can try to mount once again.

mount -t ntfs /dev/sde1 /mnt

Wednesday, January 9, 2013

mount: could not find any free loop device

mount: could not find any free loop device solution


This is the error you will get when mounting an ISO or img file. This is due to limitations of number of loop devices available in a machine. To eliminate this error we have to unmount unnecessary images before mounting any other image file in the machine.

Friday, December 14, 2012

Linux error "There are stopped jobs"

This error will come when you try to logout or exit from a terminal and there are some tasks which are running in background. 


surendra@linuxnix.com:~$ ping linuxnix.com
PING linuxnix.com (216.239.38.21) 56(84) bytes of data.
64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_req=1 ttl=50 time=61.3 ms
64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_req=2 ttl=50 time=63.2 ms
^Z
[1]+  Stopped                 ping linuxnix.com
surendra@linuxnix.com:~$ exit
There are stopped jobs.
surendra@linuxnix.com:~$ 

If you observe I started a ping program and sent that process to background. And when I try to logout from that terminal I got an error stating that there are still some programs running. To stop this error we have to see if you really like to kill the jobs.

How to kill those jobs?
Execute/press below commands/shortcuts

fg
ctrl+c


How to retain job running though you try to logout?
Just press below commands/shortcuts

ctrl+z
bg
disown

This will allow us to run the process in background though you try to logout.

 

Sunday, December 2, 2012

Solution of "No Route to Host error" Issue

No Route to Host error Linux solution

Q. I am seeing an error when trying to connect to a server, but I am able to ping and see other ports open by using telnet command? Is there a solution to resolve this issue?

First of all check what are open ports on that machine

nmap server-ip

Check if your service is running and showing in nmap output.Check if your service is running or not on tha

If your port is not open check your iptables output.

iptables -L

This will show all the rules. You can flush the iptables if you are not much concern about security.

iptables -F

Stop iptables and save iptables

service iptables stop
service iptables save

Perminently off iptables service.

chkconfig iptables off