i have written a script where a couple of the lines in the script redirect the listing of ls -ali to /dev/tty... when I envoke ls -ali on the command line i get color even on green and balck terminal.. but when the script envokes the command ls -ali to the screen no color...
i tried :
alias ls="ls -ali --color"
at the beginning of the script and got no color...
how can i get the shell script to give color as on the command line..
thanx moxxx68

This may be to do with your terminal.
Try my cecho script....
http://www.zazzybob.com/bin/tars/cecho.tar.gz
Run something like...
$ cecho red "hello"
does that produce colour output?
BTW: I think that the ls must be GNU ls to support the color option, which must be given as
$ ls --color=auto
e.g.
alias ls='ls -ali --color=auto'
Cheers
ZB
i don't want to sound a little wet behind the ears but there are certain things in linux I haven't got to yet.. and I don't know how to untar that script or download... or what I am supposed to do to make part of the system.. I know how to gunzip it but I am not sure of the rest..
also i tried
alias ls='ls -ali --color auto'
at the beginning of the script and no color.. in linux redhat 6.0 text mode i learned to implement
alias ls=`ls -ali --color' in the .bashrc file but this isn't working in the script...
here is the script;;;
# !/bin/sh
# .clear
alias ls='ls -ali --color=auto' /* new line */
function fun { clear; pwd; date; tty; }
TTY=`tty`
Dir=`dir`
echo "enter term:"
read term
if [ "$TTY" == "/dev/pts/$term" ]
then
fun
echo "Experimental Tterminal" > /dev/pts/$term
elif [ "$term" == "z" ]
then
fun
echo "Experimental Terminal"
ls -ali -R . | less > /dev/tty
elif [ "$term" == "usb" ]
then
fun
echo "//Usbterminal//" > /dev/tty
ls -ali
else
fun
case $term in
u|U) fun
echo "//usbterminal//" && egrep -nA5 '([a-z]|[0-9]\:)' * | less && ls -ali -R | less > /dev/tty
;;
e|E) fun
echo "Experimental Terminal" && egrep -nA5 '([a-z]|[0-9]\:])' * | less && ls -ali -R | less > /dev/tty
;;
a|A) fun
egrep -nA5 '([a-z]|[0-9])' * | less && ls -ali -R | less > /dev/tty
;;
x|X) fun
xterm & > /dev/tty
;;
m|M)fun
mozilla & > /dev/tty
;;
esac
fi:confused:
thanx moxxx68
i just thought about it and I figure that the alias should go on the command line or in the .bashrc file .. I am going to try this but I am not sure if i use back quotes of regualr quotes... am i heading in the right direction.. if i am i think i can figure out the rest..
than moxxx68:D
found the answer.. couldn't quite figure .bashrc or alias and i am sure there is a more functional way of writing this into the script if you or anyone has some ideas about a way to implement it in a function or know how to apply the alias code to the script I would really like to hear from you.. i tried ot implement both but didn't get far.. but this seems to work just fine;;;
# !/bin/sh
# .clear
function fun { clear; pwd; date; tty; }
TTY=`tty`
Dir=`dir`
echo "enter term:"
read term
if [ "$TTY" == "/dev/pts/$term" ]
then
fun
echo "Experimental Tterminal" > /dev/pts/$term
elif [ "$term" == "z" ]
then
fun
echo "Experimental Terminal"
ls -ali --color > /dev/tty
elif [ "$term" == "usb" ]
then
fun
echo "//Usbterminal//" > /dev/tty
ls -ali --color
else
fun
case $term in
u|U) fun
echo "//usbterminal//" && egrep -nA5 '([a-z]|[0-9]\:)' * | less && ls -ali --color > /dev/tty
;;
e|E) fun
echo "Experimental Terminal" && egrep -nA5 '([a-z]|[0-9]\:)' * | less && ls -ali --color > /dev/tty
;;
a|A) fun
egrep -nA5 '([a-z]|[0-9])' * | less && ls -ali --color > /dev/tty
;;
x|X) fun
xterm & > /dev/tty
;;
m|M)fun
mozilla & > /dev/tty
;;
esac
fi
thanx for your input and appreciate your interest.
moxxx68

just one question !
this function just gives esc sequences instead of color why...?
ls -ali -R --color | less....
it came back red..
thanx moxxx68..
cheers...!