The reason I suggested
was to see if $PATH is different in your shell and your script. (eg you have a PATH setting in your shell which isn't exported to your script) if the command above returns different values for both then call the command in the script using the full path name returned in the shell, where it worked.
I try that and it turn out to return /bin/echo both
Plus,when I type
in the script ,it work right
Can you tell me why ?
Amen to what scottn said. You'll see echo in many scripts so you should be familiar with it, but echo with any options is not portable. Do yourself a favor and learn your way around the printf(1) command (usually a shell-builtin).
Regarding your problem, perhaps your environment has aliased echo or has defined a function that overrides the builtin. In bash, the following command would indicate exactly what your shell is trying to execute (whether you type it at the command line or in a script):
Regards,
Alister
---------- Post updated at 04:05 PM ---------- Previous update was at 03:58 PM ----------
Quote:
Originally Posted by Demon
Plus,when I type
in the script ,it work right
Can you tell me why ?
When the first word contains slashes, the shell attempts to execute the executable at that location; when the first word does not contain slashes, the shell goes through a lookup process that checks for the existence of functions and builtins before it tries a $PATH lookup. In either case, aliases are expanded beforehand.
GNU bash, version 4.1.5(1)-release (i686-pc-linux-gnu)
---------- Post updated at 08:09 PM ---------- Previous update was at 07:53 PM ----------
Regarding your problem, perhaps your environment has aliased echo or has defined a function that overrides the builtin. In bash, the following command would indicate exactly what your shell is trying to execute (whether you type it at the command line or in a script):
Regards,
Alister
Both return echo is a shell builtin
Plus,when I type the command
in bash it return
--version
when I type
int bash it return
--help
But when I type /bin/echo instead of echo,everything goes right.
Anything difference between the builtin echo and the /bin/echo?
Hi,
I am using korn shell.
until ]
do
echo "\$# = " $#
echo "$1"
shift
done
To the above script, I passed 2 parameters and the program control doesn't enter inside "until" loop. If I change it to until ] then it does work.
Why numeric comparison is not working with -ne and works... (3 Replies)
I have entry in the my .profile like below, but still i see $PWD is not defied in my system
export PS1=$LOGNAME@`hostname`':'$PWD'>'
echo $PWD also gives me nothing, my env list also give no entry for PWD.Can someone help me setting PWD variable.
I use /bin/sh (9 Replies)
This is on a Solaris 9 box, but I feel like a noob, so I am posting here. When I echo $PATH I get a lot of duplicate paths and extra stuff I don't need. What I want is just what I set up in my home dir under .profile
My login shell=/bin/bash
I checked the following and there are no path... (1 Reply)
Howdie everyone...
I have a shell script RemoveFiles.sh
Inside this file, it only has two commands as below:
rm -f ../../reportToday/temp/*
rm -f ../../report/*
My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
without using ls, just using echo so purely pattern matching
I can say echo */ <-- lists directories
but how would I match files? surely something like *!/ or * but neither work ?
it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
cat .servers | while read LINE; do
ssh jason@$LINE $1
done
exit 1
./command.ksh "ls -l ~jason"
Why does this ONLY iterate on the first server in the list? It's not doing the command on all the servers in the list, what am I missing?
Thanks!
JP (2 Replies)