[ug-bosug] Problem with executing shell scripts in opensolaris

Moinak Ghosh Moinak.Ghosh at Sun.COM
Tue Jun 12 01:44:24 PDT 2007


Venkata Kishore wrote:
> Try changing the if statement to .
>
> if [ "$zonename" = 'global' ];
>
> Kishore

   Yes that seems to be the problem here. A space between "if"
   and "[" is missing causing bash to think of "if" as an array
   dereference rather a statement.

Regards,
Moinak.

>
>
> srikanth kshatriy wrote:
>>
>>
>> On 6/12/07, *Manish Chakravarty* <manishchaks at gmail.com 
>> <mailto:manishchaks at gmail.com>> wrote:
>>
>>
>>     Hi Srikanth,
>>
>>     > Am executing few shell script for my project. But bash is giving
>>     error
>>     > for
>>     > using ' ARRAY ' and ' IF '
>>     > statements. Wat may be the reason for this??
>>     >
>>     > Am using the OS : sol-nv-b60
>>     Are you sure you are invoking it with bash?
>>
>>     Unlike in (most distributions of) linux, sh is _not_ a symbolic
>>     link to bash
>>     so if you put a "#!/bin/sh" and put in bash syntax, it *will*
>>     break in
>>     Solaris.
>>     or if  you invoke a bash shell script with "sh your_script.sh" , 
>> again
>>     it will break.
>>
>>     It could be helpful if you provide us with your shell script. 
>> (and how
>>     you invoked it).
>>
>>     Thanks
>>     Manish
>>
>>     _______________________________________________
>>     ug-bosug mailing list
>>     List-Unsubscribe: mailto:ug-bosug-unsubscribe at opensolaris.org
>>     <mailto:ug-bosug-unsubscribe at opensolaris.org>
>>     List-Owner: mailto: ug-bosug-owner at opensolaris.org
>>     <mailto:ug-bosug-owner at opensolaris.org>
>>     List-Archives: http://www.opensolaris.org/jive/forum.jspa?forumID=54
>>
>>
>>
>> Hello sir,
>>
>> #!/bin/bash
>>
>> for zonedata in `zoneadm list -cp | cut -d: -f2-4`
>> do
>> #echo $zonedata
>> zonename=`echo $zonedata | cut -d: -f1`
>> #echo $zonename
>> if[ "$zonename" = 'global' ]
>> then
>> host=`uname -n`
>> zonedata="$zonedata:$host"
>> echo $zonedata
>> fi
>> done
>>
>>
>> This is my sample script. Still i ve to do lot more in this. I  had 
>> removed the array concept
>> from this. Now its giving error in " then " line[ IF statement ]. As 
>> u guessed am  invoking
>> it with "sh script_name.sh". This is the procedure what i found  for 
>> shell scripting in net.
>>
>> Wat is the procedure to accomplish this in solaris?
>>
>>
>>
>>
>> Thanks,
>>  Srikanth.
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> ug-bosug mailing list
>> List-Unsubscribe: mailto:ug-bosug-unsubscribe at opensolaris.org
>> List-Owner: mailto:ug-bosug-owner at opensolaris.org
>> List-Archives: http://www.opensolaris.org/jive/forum.jspa?forumID=54
>>   
>
> _______________________________________________
> ug-bosug mailing list
> List-Unsubscribe: mailto:ug-bosug-unsubscribe at opensolaris.org
> List-Owner: mailto:ug-bosug-owner at opensolaris.org
> List-Archives: http://www.opensolaris.org/jive/forum.jspa?forumID=54




More information about the ug-bosug mailing list