Humour: Funny Behaviour of rm Command

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@localhost pub]# ll
total 1648
-rw-r--r--  1 root root  85648 Jun  5 23:52 14thtop.png
-rw-r--r--  1 root root 262852 Jun  5 23:52 orkuthelper.png
-rw-r--r--  1 root root 143804 Jun  5 23:52 shot1.png
-rw-r--r--  1 root root 160552 Jun  5 23:52 shot2.png
-rw-r--r--  1 root root 159934 Jun  5 23:52 shot3.png
-rw-r--r--  1 root root 141849 Jun  5 23:52 shot4.png
lrwxrwxrwx  1 root root      9 Jun  4 18:44 windows -> /windows/
[root@localhost pub]# rmdir windows/
rmdir: 'windows/': Not a directory
[root@localhost pub]# rm windows/
rm: cannot remove directory 'windows/': Is a directory
[root@localhost pub]#

can you just tell me how to remove this directory? plz… urgent help required …

 

How To: Troubleshoot SCP Command

Some times we face problems in transferring the data from one machine to other machine using scp. Actually the scp command is executed successfully but the data is not transferred. As the .bashrc and not the .bash_profile file of the system to which the data is being transferred is executed. If the .bashrc of the remote system contains any command or executable which output some data to the standard output then that command is executed and the output is flushed on the local machine and the scp command is terminated and data is not transferred.

For example if the remote machine has any ‘echo’ or ‘nfrm’ command in .bashrc file, the scp of the data will not be possible.
Also suppose the remote machine has a lines in .bashrc like this

./test.sh

where test.sh contains the data as below:-

1
2
#/usr/bin/sh
echo "Kulbir Saini"

Then also the scp will not be possible.

So if you are facing such problems please try to remove such lines from your .bashrc file and scp the data you want.
Anyway you can keep those lines in your .bash_profile because it is not executed while transferring the data.

Please report any other cases in which scp is not possible.

 

Hack: Graphical Implementation of CP Command

To use this graphical interface do as directed below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
##############################
# Author - Kulbir Saini      #
# Home - http://saini.co.in/ #
##############################
 
if [ $1 == -i ] || [ $1 == -f ];then          
	if [ ! -s $2 ] && [ ! -f $2 ] && [ ! -d $2 ];then
		dialog --title "Copy daemon" --backtitle "copy:" --infobox "file:$2 doesn't exist.\nCan't copy...\nPress any key..." 5 30; read
	elif [ ! $3 ];then
		dialog --title "Copy daemon" --backtitle "copy:" --infobox "Invalid arguements...\nCan't copy...\nPress any key..." 5 30; read
	elif [ -d $3 ];then
		dialog --title "Copy daemon" --backtitle "copy:" --infobox "$3: is a directory.\nCan't copy...\nPress any key..." 5 30; read
	elif [ -d $2 ];then
		dialog --title "Copy daemon" --backtitle "copy:" --infobox "$2: is a directory.\nCan't copy...\nPress any key..." 5 30; read
	elif [ -s $3 -o -f $3 ];then
		dialog --title "Copy daemon" --backtitle "copy:" --yesno "Do you want to overwrite file:$3" 10 60;
		select=$?
		case $select in 
			0) echo -e "i'm ordered to overwrite file:$3 \noverwriting...\noverwritten file:$3" ; cp -f $2 $3 ;;
			1) echo "i'm ordered not to overwrite.";;
			255) echo "cancelled by you by pressing [Esc].";;
		esac
	else
		dialog --title "Copy daemon" --backtitle "copy:" --yesno "Do you want to copy the file:$2 to file:$3" 10 60 ;
		select1=$?
		case $select1 in
			0) echo -e "i'm ordered to copy file:$2 to file:$3 \ncopying...\ncopied to file:$3" ; cp $2 $3 ;;
			1) echo "i'm ordered not to copy.";;
			255) echo "cancelled by you by pressing [Esc].";;
		esac
	fi
elif [ ! -s $1 ] && [ ! -f $1 ] && [ ! -d $1 ];then
	dialog --title "Copy daemon" --backtitle "copy:" --infobox "file:$1 doesn't exist.\nCan't copy...\nPress any key..." 5 30; read
elif [ ! $2 ];then
	dialog --title "Copy daemon" --backtitle "copy:" --infobox "Invalid arguements...\nCan't copy...\nPress any key..." 5 30; read
elif [ -d $2 ];then
	dialog --title "Copy daemon" --backtitle "copy:" --infobox "$2: is a directory.\nCan't copy...\nPress any key..." 5 30; read
elif [ -d $1 ];then
	dialog --title "Copy daemon" --backtitle "copy:" --infobox "$1: is a directory.\nCan't copy...\nPress any key..." 5 30; read
elif [ -s $2 -o -f $2 ];then
	dialog --title "Copy daemon" --backtitle "copy:" --yesno "Do you want to overwrite file:$2" 10 60;
	select=$?
	case $select in 
		0) echo -e "i'm ordered to overwrite file:$2 \noverwriting...\noverwritten file:$2" ; cp -f $1 $2 ;;
		1) echo "i'm ordered not to overwrite.";;
		255) echo "cancelled by you by pressing [Esc].";;
	esac
else
	dialog --title "Copy daemon" --backtitle "copy:" --yesno "Do you want to copy the file:$1 to file:$2" 10 60 ;
	select1=$?
	case $select1 in
		0) echo -e "i'm ordered to copy file:$1 to file:$2 \ncopying...\ncopied to file:$2" ; cp $1 $2 ;;
		1) echo "i'm ordered not to copy.";;
		255) echo "cancelled by you by pressing [Esc].";;
	esac
fi

1. Get the script here .

2. Move it to a file named ‘copy’.

3. Create a director ‘bin’ in your home directory.

4. Write

export PATH=$PATH:${HOME }/bin/

to your ~/.bashrc file.

5. Execute .bashrc by issuing

[saini@localhost ~]# . .bashrc

6. If you want to copy a file foo.txt to bar.txt then do it as

[saini@localhost ~]# copy foo.txt bar.txt [Enter]

Done.