在搞乱>&,/ dev / null等之后,BASH命令$ifconfig -all
不再回显屏幕的输出。
如何解决这个问题?
它位于Raspberry Pi的Debian操作系统上。
这就是我得到的:
pi@raspberrypi ~ $ sudo ifconfig -all
pi@raspberrypi ~ $
对罗宾格林答案的回应:
pi@raspberrypi ~ $ ifconfig -all
pi@raspberrypi ~ $ exec 2>&1 >/dev/stdout
pi@raspberrypi ~ $ exec 2>&1 >/dev/tty
pi@raspberrypi ~ $ ifconfig -all
pi@raspberrypi ~ $
历史输出:
657 # Copyright: Copyright (c) 2012 Kevin Reed <kreed@tnet.com>
693 if [ -e $lockfile ]; then pid=`cat $lockfile`; if kill -0 &>1 > /dev/null $pid; then exit 1; else rm $lockfile; fi; fi
696 echo $$ > $lockfile
699 /bin/ping -c 2 -I $wlan $pingip > /dev/null 2> /dev/null
753 sudo /sbin/ifconfig >>
754 sudo /sbin/ifconfig >
755 sudo /sbin/ifconfig > tty01
756 sudo /sbin/ifconfig > tty1
757 sudo /sbin/ifconfig >> tty1
758 sudo /sbin/ifconfig >> echo
759 sudo /sbin/ifconfig > echo
784 exec 2>&1 >/dev/tty
786 exec 2>&1 >/dev/stdout
790 sudo exec 2>&1 >/dev/stdout
791 exec 2>&1 >/dev/stdout
792 sudo exec 2>&1 >/dev/tty
794 ifconfig 2>&1 >/dev/stdout
795 ifconfig 2>&1 >/dev/tty
803 sudo ifconfig 2>&1 >/dev/tty
805 sudo exec 2>&1 >/dev/tty
806 exec 2>&1 >/dev/tty
807 exec 2>&1 >/dev/stdout
811 exec 2>&1 >/dev/stdout
812 exec 2>&1 >/dev/tty
814 history | egrep '>|<'
我在历史中看到我不小心输入了一个不应该在那里明显推出的bash脚本:
648 #!/bin/bash
649 ##################################################################
650 # A Project of TNET Services, Inc
651 #
652 # Title: WiFi_Check
653 # Author: Kevin Reed (Dweeber)
654 # dweeber.dweebs@gmail.com
655 # Project: Raspberry Pi Stuff
656 #
657 # Copyright: Copyright (c) 2012 Kevin Reed <kreed@tnet.com>
658 # https://github.com/dweeber/WiFi_Check
659 #
660 # Purpose:
661 #
662 # Script checks to see if WiFi has a network IP and if not
663 # restart WiFi
664 #
665 # Uses a lock file which prevents the script from running more
666 # than one at a time. If lockfile is old, it removes it
667 #
668 # Instructions:
669 #
670 # o Install where you want to run it from like /usr/local/bin
671 # o chmod 0755 /usr/local/bin/WiFi_Check
672 # o Add to crontab
673 #
674 # Run Every 5 mins - Seems like ever min is over kill unless
675 # this is a very common problem. If once a min change */5 to *
676 # once every 2 mins */5 to */2 ...
677 #
678 # */5 * * * * /usr/local/bin/WiFi_Check
679 #
680 ##################################################################
681 # Settings
682 # Where and what you want to call the Lockfile
683 lockfile='/var/run/WiFi_Check.pid'
684 # Which Interface do you want to check/fix
685 wlan='wlan0'
686 pingip='192.168.1.1'
687 ##################################################################
688 echo
689 echo "Starting WiFi check for $wlan"
690 date
691 echo
692 # Check to see if there is a lock file
693 if [ -e $lockfile ]; then pid=`cat $lockfile`; if kill -0 &>1 > /dev/null $pid; then exit 1; else rm $lockfile; fi; fi
694 # If we get here, set a lock file using our current PID#
695 #echo "Setting Lockfile"
696 echo $$ > $lockfile
697 # We can perform check
698 echo "Performing Network check for $wlan"
699 /bin/ping -c 2 -I $wlan $pingip > /dev/null 2> /dev/null
700 if [ $? -ge 1 ] ; then echo "Network connection down! Attempting reconnection."; /sbin/ifdown $wlan; /bin/sleep 5; /sbin/ifup --force $wlan; else echo "Network is Okay"; fi
701 echo
702 echo "Current Setting:"
703 /sbin/ifconfig $wlan | grep "inet addr:"
704 echo
705 # Check is complete, Remove Lock file and exit
706 #echo "process is complete, removing lockfile"
707 rm $lockfile
708 exit 0
709 ##################################################################
710 # End of Script