Shell Script problem $( vs ticks [`]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script problem $( vs ticks [`]
# 1  
Old 07-08-2010
Shell Script problem $( vs ticks [`]

ok so, I recently started using
Code:
$(echo one two three)

to execute commands in scripts instead of using
Code:
`echo one two three`

.

This method works wonderfully on ubuntu. However, it doesn't seem to work on other unix systems, i.e redhat/sun sun solaris.

I really hate to go back to the ticks "`" so i'm wondering if anyone here knows of a way around this.

when i run a script containing GECKO=$(echo one two three) on a non-ubuntu box, i get some type of error similar to :

Code:
: syntax error at line 175: `MONTH=$' unexpected

i have tried using different shells - bash, ksh, sh - same thing.

Any suggestions?
# 2  
Old 07-08-2010
On Solaris /bin/sh for some strange reason still points to an actual real Bourne Shell instead of a POSIX shell. Try to using a POSIX shell by putting
Code:
#!/usr/xpg4/bin/sh

as the first line of your script (I believe it is pointing to a ksh), or use ksh93 that possibly is available on your system.

Quote:
Originally Posted by SkySmart
.. i have tried using different shells - bash, ksh, sh - same thing.
That is strange. The first two should understand $( ).

Last edited by Scrutinizer; 07-08-2010 at 02:32 AM..
# 3  
Old 07-09-2010
Thank you so much. your suggestion worked Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Back ticks and $()

In one of my previous threads, someone suggested not to use backticks. When I googled, I came to know that back ticks are deprecated instead $() should be used. But I face issue while using $(). Note: I used echo of the sql just to debug. The following is the code #!/bin/ksh #set -x... (5 Replies)
Discussion started by: bobbygsk
5 Replies

2. Shell Programming and Scripting

Shell script newbie, what is problem with my script?

Hello, Ubuntu server 11.10 can anybody help what is problem with my shell script? #!/bin/bash #script to find out currently logged on user is root or not. if ] then echo "You are super" else echo "You are awesome!" fi When I run script, I get following output ./uid: line 3: I... (4 Replies)
Discussion started by: kaustubh
4 Replies

3. Shell Programming and Scripting

Passing variable to Expression in back ticks.

Hi, In my perl script I want to check whether *.csv files exist and take the count . Below is the code: $path = “/home/usr/jan/myfiles” my $File_Count = `ls *.csv | wc -l `; # Checks in the current directory #Works fine if files exists. my $File_Count = `ls $path/*.csv | wc -l `; # I need... (2 Replies)
Discussion started by: jisha
2 Replies

4. Shell Programming and Scripting

shell script , $$ problem

dialog --title "Inputbox - To take input from you" --backtitle "Linux Shell\ Script Tutorial" --inputbox "Enter your name please" 8 60 2>/tmp/input.$$ sel=$? na=`cat /tmp/input.$$` case $sel in 0) echo "Hello $na" ;; 1) echo "Cancel is Press" ;; 255) echo " key pressed" ;; ... (7 Replies)
Discussion started by: cola
7 Replies

5. Shell Programming and Scripting

shell script problem

Hey there, I`m a beginner so don`t be brutall with me if it`s a stupid or easy question. I need to make a script that 1) reads from a text file with this pattern: 2) and i need it to insert the #defines in the .c files Problem is, that i`m working in a batch file,from within... (3 Replies)
Discussion started by: mad_igor
3 Replies

6. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

7. Shell Programming and Scripting

Problem in shell script

HOSTNAME=`uname -n` /usr/sbin/clinfo CLUSTERACTIVE=$? # First check whether the Cluster itself is active if then echo Cluster is NOT ACTIVE - EXITING exit 1 fi # Now check whether we are on the active Cluster Node for this Resource Group... (2 Replies)
Discussion started by: babu.knb
2 Replies

8. HP-UX

Ticks in seconds.

Hello all, Is there any thumb rule or aproximation of the equivalence in second of one tick? Thank you in advance. (1 Reply)
Discussion started by: mig28mx
1 Replies

9. Shell Programming and Scripting

shell script problem

shell script for sorting,searchingand insertion/deletion of elements in a list (1 Reply)
Discussion started by: jayaram_miryabb
1 Replies
Login or Register to Ask a Question