4bffe0ce80eaf067a4eb89adf8a5888a02402c3a
[dotfiles] / .bash_function
1 #!/bin/sh
2 # my weird function file
3 # lots of this coming from the internets
4
5
6
7 # _ssh_agent() {
8 # command -v ssh-agent >/dev/null || return
9 # [ "$SSH_CONNECTION" ] && return
10 # local info=$HOME/.cache/ssh-agent-info
11 # [ -f $info ] && . $info >/dev/null
12 # [ "$SSH_AGENT_PID" ] && kill -0 $SSH_AGENT_PID 2>/dev/null || {
13 # mkdir -p $(dirname $info)
14 # ssh-agent >$info
15 # . $info >/dev/null
16 # }
17 # } _ssh_agent
18
19
20 _ssh_add() {
21 local key=$1
22
23 [ "$SSH_CONNECTION" ] && return
24 ssh-add -l | grep $key >/dev/null || ssh-add $key
25 }
26
27 ssh() {
28 local remote=$1
29
30 case $remote in
31 "vm1") _ssh_add $HOME/.ssh/id_rsa_kratos ;;
32 "phobos") _ssh_add $HOME/.ssh/id_rsa_phobos ;;
33 *) #echo "valid key not found" && exit 1 ;;
34 esac
35 command ssh "$@"
36 }
37
38 # scp() {
39 # local file=$1
40 # local remote=$2
41
42 # case $remote in
43 # "vm1:") _ssh_add $HOME/.ssh/id_rsa_kratos ;;
44 # "phobos:") _ssh_add $HOME/.ssh/id_rsa_phobos ;;
45 # esac
46
47 # command scp "$@"
48 # }
49
50
51 # git() {
52 # case $1 in
53 # push|pull|fetch) _ssh_add ;;
54 # esac
55 # command git "$@"
56 # }
57
58 my_reboot_br0(){
59 sudo ifdown br0
60 my_up
61 }
62
63 my_up(){
64 ifup br0 &&
65 echo "nameserver 80.67.169.12" | sudo tee /etc/resolv.conf
66 }
67
68 my_weather(){
69 local town=$1
70 curl -4 "http://wttr.in/"$town
71 }
72
73 my_dotargz(){
74 local tarfile=$1
75 local foldertobezipped=$2
76 tar -zcvf $1 $2
77 #tar -cvf - file1 file2 dir3 | gzip > archive.tar.gz
78 }
79
80 my_dotarbz2(){
81 local tarfile=$1
82 local foldertobezipped=$2
83 tar -jcvf $1 $2
84
85 }
86
87 # zip some files using python
88 my_zipit(){
89 local zipfile=$2
90 local tobezipped=$1
91 # call the zip module from python3
92 python3 -m zipfile -c $2 $1
93 }
94
95 # to unban an ip blocked because of fail ssh connection
96 my_fail2ban_unban_ip(){
97 local ip=$1
98 sudo fail2ban-client set ssh unbanip $ip
99
100 }
101
102 my_bak() { cp "$1" "$1_`date +%Y-%m-%d_%H-%M-%S`" ; }
103
104 my_whois_onport(){
105 # return the service on port
106 local port=$1
107 sudo lsof -i :$port
108 }
109
110 my_mount_set_of_partition(){
111 # Mount set of partitions for recovery.
112 for i in {1..12}; do
113 mkdir /media/sdd$i && mount -o ro /{dev,media}/sdd$i || rmdir /media/sdd$i ;
114 done
115 }
116
117 my_copy_file_to_clipboard() {
118 local filecontent=$1
119 [ -f $file ] && xclip -sel clip < $filecontent
120 }
121
122 my_usage() {
123
124 cat <<-EOF
125 usage: $PROGNAME options
126
127 Program deletes files from filesystems to release space.
128 It gets config file that define fileystem paths to work on, and whitelist rules to
129 keep certain files.
130
131 OPTIONS:
132 -c --config configuration file containing the rules. use --help-config to see the syntax.
133 -n --pretend do not really delete, just how what you are going to do.
134 -t --test run unit test to check the program
135 -v --verbose Verbose. You can specify more then one -v to have more verbose
136 -x --debug debug
137 -h --help show this help
138 --help-config configuration help
139
140
141 Examples:
142 Run all tests:
143 $PROGNAME --test all
144
145 Run specific test:
146 $PROGNAME --test test_string.sh
147
148 Run:
149 $PROGNAME --config /path/to/config/$PROGNAME.conf
150
151 Just show what you are going to do:
152 $PROGNAME -vn -c /path/to/config/$PROGNAME.conf
153
154 EOF
155 }
156
157 my_change_owner_of_files() {
158 local user=$1; shift
159 local group=$1; shift
160 local files=$@
161 local i
162
163 for i in $files
164 do
165 chown $user:$group $i
166 done
167 }
168
169
170 my_template_function() {
171 # local vars
172 local PROGNAME=$(basename $0)
173 local PROGDIR=$(readlink -m $(dirname $0))
174 local ARGS="$@"
175 local first_arg=$1
176
177 # readonly var
178 #readonly local second_arg=$2;
179
180 # if no args, print usage
181 is_empty_string $ARGS && my_usage
182
183
184 }
185
186 my_list_venv(){
187 ls $HOME"/envs"
188 }
189
190 my_goto_venv() {
191 local dir=$1
192 local env=$HOME"/envs/"$dir"/source/"
193 #if source dir not exists, create & cd
194 [ -d $env ] && cd $env || mkdircd -p $env
195 # activate virtualenv
196 source $HOME"/envs/"$dir"/bin/activate"
197 }
198
199 # Taken from http://aaroncrane.co.uk/2009/03/git_branch_prompt/
200 find_git_repo() {
201 local dir=.
202 until [ "$dir" -ef / ]; do
203 if [ -f "$dir/.git/HEAD" ]; then
204 GIT_REPO=`readlink -e $dir`/
205 return
206 fi
207 dir="../$dir"
208 done
209 GIT_REPO=''
210 return
211 }
212
213 find_git_branch() {
214 head=$(< "$1/.git/HEAD")
215 if [[ $head == ref:\ refs/heads/* ]]; then
216 GIT_BRANCH=${head#*/*/}
217 elif [[ $head != '' ]]; then
218 GIT_BRANCH='(detached)'
219 else
220 GIT_BRANCH='(unknown)'
221 fi
222 }
223
224 # Taken from https://github.com/jimeh/git-aware-prompt
225 find_git_dirty() {
226 local status=$(git status --porcelain 2> /dev/null)
227 if [[ "$status" != "" ]]; then
228 GIT_DIRTY='*'
229 else
230 GIT_DIRTY=''
231 fi
232 }
233
234 find_git_stash() {
235 if [ -e "$1/.git/refs/stash" ]; then
236 GIT_STASH='stash'
237 else
238 GIT_STASH=''
239 fi
240 }
241
242 cdls() { cd "$@" && clear && ls; }
243
244
245 cl(){
246 if [ -d "$1" ]; then
247 cd "$1"
248 clear
249 ls -lh
250 else
251 cd
252 clear
253 ls
254 fi
255 }
256
257
258 mkdircd(){
259 mkdir -p "$@" && eval cd "\"\$$#\"";
260 }
261
262 my_emacs_servers(){
263 local serverdir="${TMPDIR:-/tmp}/emacs${UID}"
264 local -a servers
265 for file in ${serverdir}/*; do
266 if [[ -S ${file} ]]; then
267 servers+=("${file##*/}")
268 fi
269 done
270
271 echo "${servers[@]}"
272 }
273
274 my_fib(){
275 x=${1:-1}
276 y=${2:-1}
277 echo $(($x + $y))
278 fib $y $(($x + $y))
279 }
280
281
282 my_recursiveFibo() {
283 local start=0;
284 n="$1";
285 inc="$2";
286 while ((n < $inc));
287 do
288 result=$((start+n));
289 start=$n;
290 n="$result";
291 printf '%s ' "$result";
292 done;
293 }
294
295 #recursivFibo 1 2048
296
297 my_err() {
298 echo "[$(date + '%Y-%m-%dT%H:%M:%S%z')]: $@ >&2"
299 }
300
301 my_test() {
302 echo 'test';
303 }
304
305 my_test2(){
306 if my_test; then
307 my_err "unable to my_test"
308 exit "${E_DID_NOTHING}"
309 fi
310 }
311
312 my_pretty_print_json() {
313 python -m json.tool
314 }
315
316 my_not_start_service_on_boot(){
317 # service to not start on boot
318 local service=$1;
319 update-rc.d $service disable;
320 }
321
322 my_install_new_font(){
323 #sudo fc-cache -v -f
324 fc-cache -v -f;
325 }
326
327 my_launch_eth0(){
328 # set eth0 iface up
329 sudo ip link set eth0 up;
330 # ask for an ip via dhcp
331 sudo dhclient eth0;
332 }
333
334 #function to show the current branch
335 my_show_current_branch(){
336 git rev-parse --abbrev-ref HEAD
337 }
338
339 my_pdf_nbpages(){
340 local filename=$1;
341
342 echo $(pdftk $filename dump_data \
343 | grep -i numberofpages \
344 | awk '{print $2}');
345 }
346
347 my_pdf_explosion() {
348 local filename=$1;
349 echo $(pdftk $filename burst);
350 }
351
352 my_pdfs_to_xml() {
353 for i in $(ls | grep .pdf$); do
354 pdftohtml -xml $i;
355 done;
356 }
357
358 # function to show one line of file
359 my_xline_of_file(){
360 local line_number=$1;
361 local filename=$2;
362 local p='p';
363
364 echo $(sed -n $line_number$p $filename);
365 }
366
367 # function to extract in one command
368 my_xtract() {
369 local filename=$1;
370
371 if is_file $filename ; then
372 case $filename in
373 *.tar.xz) tar xvfJ $filename ;;
374 *.xz) tar xf $filename ;;
375 *.tar.bz2) tar xvjf $filename ;;
376 *.tar.gz) tar xvzf $filename ;;
377 *.bz2) bunzip2 $filename ;;
378 *.rar) unrar x $filename ;;
379 *.gz) gunzip $filename ;;
380 *.tar) tar xvf $filename ;;
381 *.tbz2) tar xvjf $filename ;;
382 *.tgz) tar xvzf $filename ;;
383 *.zip) unzip $filename ;;
384 *.Z) uncompress $filename ;;
385 *.7z) 7z x $filename ;;
386 *) echo "'$filename' cannot be extracted via extract" ;;
387 esac
388 else
389 echo "'$filename' is not a valid file"
390 fi
391 }
392
393 # function to list the content of an archive
394 my_list_archive_content() {
395 local filename=$1;
396
397 if is_file $filename ; then
398 case $filename in
399 *.tar.xz) tar tvfJ $filename ;;
400 *.tar.bz2) tar tvjf $filename ;;
401 *.tar.gz) tar tzvf $filename ;;
402 *.bz2) bunzip2 $filename ;;
403 *.gz) gunzip -l $filename ;;
404 *.tar) tar tvf $filename ;;
405 *.tbz2) tar tvjf $filename ;;
406 *.tgz) tar tvzf $filename ;;
407 *.zip) unzip -l $filename ;;
408 *.Z) uncompress -l $filename ;;
409 *.7z) 7z l $filename ;;
410 *) echo "content of '$filename' cannot be listed :(" ;;
411 esac
412 else
413 echo "'$filename' is not a valid file"
414 fi
415 }
416
417 # dump a mysql database
418 my_dump_mysql_db() {
419 local database=$1;
420
421 echo "dumping database '$database' ..."
422 mysqldump -u patrick -ppatrick $database > $databse_dump_$(date +%m%d%Y).sql
423
424 }
425
426 my_dump_mysql_table() {
427 local database=$1;
428 local table=$2;
429
430 echo "dumping table '$table' from database '$database' ..."
431 mysqldump -u patrick -ppatrick $database $table > $table_dump_$(date +%m%d%Y).sql
432 }
433
434 my_uploadfile() {
435 local filename=$1
436 local ftp_url=$2;
437 local user=$3;
438 local password=$4;
439
440 echo "upload of '$filename' to '$ftp_url' by '$user' ..."
441 #curl -T $filename ftp://dev.africafilms.tv/movies/ --user dev.africafilms.tv:dev/aftv/DAK2602
442 curl -T $filename $ftp_url --user $user:$password
443 }
444
445 my_find_string() {
446 local string_to_find=$1;
447 local directory=$2;
448
449 echo "recursive looking for the string '$string' inside '$directory' directory"
450 grep -l -R -i -r $string_to_find $directory;
451 }
452
453 my_find_string2() {
454 local string_to_find=$1;
455 local directory=$2;
456
457 echo "recursive looking for the string '$string' inside '$directory' directory"
458 find $directory | xargs grep $string -sl;
459
460 }
461 # extract md5 hash from a string
462 my_xmd5() {
463 local string=$1;
464
465 echo "md5 hash of '$string' is: "
466 echo -n "$string" | md5sum;
467 }
468
469 # Creates an archive (*.tar.gz) from given directory.
470 my_maketar() {
471 local directory=$1;
472
473 tar cvzf "${directory%%/}.tar.gz" "${directory%%/}/";
474 }
475
476 # Create a ZIP archive of a file or folder.
477 my_makezip() {
478 local file=$1;
479
480 zip -r "${file%%/}.zip" "$file";
481 }
482
483 # Make your directories and files access rights sane.
484 my_sanitize() { chmod -R u=rwX,g=rX,o= "$@" ;}
485
486 # Get IP adress on ethernet.
487 my_ip() {
488 local my_ip=$( /sbin/ifconfig eth0 \
489 | awk '/inet/ { print $2 } ' \
490 | sed -e s/addr://);
491 local my_gtw="gtw: "$(netstat -nr | awk '{print $2}' | sed -n 3p);
492 echo ${my_ip:-"Not connected"}
493 echo ${my_gtw:-"Not connected"}
494 }
495
496 # Get current host related info.
497 my_host_info() {
498 echo -e "\nYou are logged on ${BRed}$HOST"
499 echo -e "\n${BRed}Local IP Address :$NC" ; my_ip
500 echo -e "\n${BRed}Current date :$NC " ; date; calendar | head -1
501 echo -e "\n${BRed}Additionnal information:$NC " ; uname -a
502 echo -e "\n${BRed}Users logged on:$NC " ; \
503 w -hs \
504 | cut -d " " -f1 \
505 | sort \
506 | uniq
507 echo -e "\n${BRed}Machine stats :$NC " ; uptime
508 echo -e "\n${BRed}Memory stats :$NC " ; free -h
509 echo -e "\n${BRed}Diskspace :$NC " ; mydf / $HOME
510 echo -e "\n${BRed}Open connections :$NC "; netstat -pan --inet;
511 echo
512 }
513
514 # Pretty-print of 'df' output. Inspired by 'dfc' utility.
515 my_df() {
516 local fs=$1;
517
518 for fs ; do
519
520 if [ ! -d $fs ]
521 then
522 echo -e $fs" :No such file or directory" ; continue
523 fi
524
525 local info=( $(command df -P $fs | awk 'END{ print $2,$3,$5 }') )
526 local free=( $(command df -Pkh $fs | awk 'END{ print $4 }') )
527 local nbstars=$(( 20 * ${info[1]} / ${info[0]} ))
528 local out="["
529 for ((j=0;j<20;j++)); do
530 if [ ${j} -lt ${nbstars} ]; then
531 out=$out"*"
532 else
533 out=$out"-"
534 fi
535 done
536 out=${info[2]}" "$out"] ("$free" free on "$fs")"
537 echo -e $out
538 done
539 }
540
541 # create_vm(){
542 # debootstrap --verbose \
543 # --variant=minbase \
544 # --arch=i386 --include ifupdown,locales,libui-dialog-perl,dialog,dhcp3-client,netbase,net-tools,iproute,openssh-server \
545 # sid /var/lib/lxc/sid http://ftp.debian.org/debian
546
547 # }
548
549
550 my_add_todo(){
551 local rememberfile="$HOME/.remember"
552 # if the file not exists, touch it
553 [[ ! -f $rememberfile ]] && touch $rememberfile
554 if [ $# -eq 0 ] ; then
555 echo "Type what you want to remember then, hit ^D: "
556 cat - >> $rememberfile;
557 else
558 #echo $(date +%m%d%Y)" -- $@" >> $rememberfile
559 echo $(date +%F)" -- $@" >> $rememberfile
560 fi
561 }
562
563 my_reminder(){
564 local rememberfile="$HOME/.remember"
565
566 #is_not_file $remberfile && echo 'nothing to do' ||
567 #is_empty $rememberfile && echo 'nothing to do' ||
568 #display_todo "$@"
569 is_not_file $rememberfile || [[ $(cat $rememberfile | wc -l) = 0 ]] && echo "nothing to do" || my_display_todo "$@";
570 }
571
572 my_display_todo(){
573
574 local rememberfile="$HOME/.remember"
575 echo $#;
576 #[[ $# -eq 0 ]] && more $rememberfile || grep -i "$@" $rememberfile | more;
577 [[ $# -eq 0 ]] && is_file $rememberfile && is_not_empty_file $rememberfile && cat $rememberfile || grep -i "$@" $rememberfile;
578 }
579
580
581 my_lsbytesum() {
582 #lsbytesum - sum the number of bytes in a directory listing
583 TotalBytes=0
584 for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }')
585 do
586 let TotalBytes=$TotalBytes+$Bytes
587 done
588 TotalMeg=$(echo -e "scale=3 \n$TotalBytes/1048576 \nquit" | bc)
589 echo -n "$TotalMeg"
590 }
591
592 # list
593 my_create_list(){
594 local listname=$1;
595 declare -a $listname;
596 }
597
598 # sensonet
599
600 sensonet_create_event() {
601 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/events/"$2"
602 }
603
604 sensonet_update_event() {
605 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/events/"$2"
606 }
607
608 sensonet_events() {
609 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/ || \
610 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/"$1"
611 }
612
613 sensonet_del_event() {
614 curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/"$1"
615 }
616
617 sensonet_create_sensor() {
618 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "description=$1" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$2"
619 }
620
621 sensonet_update_sensor() {
622 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "description=$1" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$2"
623 }
624
625 sensonet_del_sensor() {
626 curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$1"
627 }
628
629 sensonet_sensors() {
630 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/ || \
631 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$1"
632 }
633
634 sensonet_create_network(){
635 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$2"
636 }
637
638 sensonet_update_network(){
639 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$2"
640 }
641
642 sensonet_del_network(){
643 curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"
644 }
645
646 sensonet_networks(){
647 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/ || \
648 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"
649 }
650
651 sensonet_network_probes() {
652 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"/probes
653 }
654
655 sensonet_create_probe() {
656 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" \
657 -d "name=${1}&latitude=0.0&longitude=0.0&monitorMe=1&sleepingTime=0&networkId=univlab" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
658 }
659
660 sensonet_update_probe() {
661 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" \
662 -d "name=${1}&latitude=48.0&longitude=-1.0&monitorMe=1&sleepingTime=0" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
663 }
664
665 sensonet_probes() {
666 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/ || \
667 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"
668 }
669
670 sensonet_del_probe() {
671 curl -i -X "DELETE" -k -H -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
672 }
673
674 sensonet_probe_neighborhood(){
675 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/neighborhood
676 }
677
678 sensonet_probe_set_sleeping_time(){
679 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "duration=${2}" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sleepingtime
680 }
681
682 sensonet_probe_sensors(){
683 [[ $# -eq 1 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors || \
684 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors/"${2}"
685 }
686
687 sensonet_probe_sensor_values(){
688 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors/"${2}"/values
689 }
690
691 # from nixcraft
692 # Show top 10 history command on screen
693 function ht {
694 history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
695 }
696
697 # Wrapper for host and ping command
698 # Accept http:// or https:// or ftps:// names for domain and hostnames
699 _getdomainnameonly(){
700 local h="$1"
701 local f="${h,,}"
702 # remove protocol part of hostname
703 f="${f#http://}"
704 f="${f#https://}"
705 f="${f#ftp://}"
706 f="${f#scp://}"
707 f="${f#scp://}"
708 f="${f#sftp://}"
709 # remove username and/or username:password part of hostname
710 f="${f#*:*@}"
711 f="${f#*@}"
712 # remove all /foo/xyz.html*
713 f=${f%%/*}
714 # show domain name only
715 echo "$f"
716 }
717
718
719 ping(){
720 local array=( $@ ) # get all args in an array
721 local len=${#array[@]} # find the length of an array
722 local host=${array[$len-1]} # get the last arg
723 local args=${array[@]:0:$len-1} # get all args before the last arg in $@ in an array
724 local _ping="/bin/ping"
725 local c=$(_getdomainnameonly "$host")
726 [ "$t" != "$c" ] && echo "Sending ICMP ECHO_REQUEST to \"$c\"..."
727 # pass args and host
728 $_ping $args $c
729 }
730
731 host(){
732 local array=( $@ )
733 local len=${#array[@]}
734 local host=${array[$len-1]}
735 local args=${array[@]:0:$len-1}
736 local _host="/usr/bin/host"
737 local c=$(_getdomainnameonly "$host")
738 [ "$t" != "$c" ] && echo "Performing DNS lookups for \"$c\"..."
739 $_host $args $c
740 }