views:

203

answers:

2

Hi, I am using busybox shell to execute a script which the bash executes when i boot linux using the nfs. Please let me know the correct alternative for this line.

cur_major=$((0x`stat -c %t $dev 2>/dev/null`))

The busybox throws in an error saying "0x" syntax error, which i understand is the problem with the syntax of this line.

Thanks in advance

A: 

I don't have a problem running it. try doing it step by step if all else fails.

$ var=$(stat -c "%t" $dev 2>/dev/null)
$ var=$((0x$var))

actually $(()) lets you perform arithmetic. what is it actually you are trying to do? are you trying to convert to a hex number?

ghostdog74
Hi, Thanks for a very quick reply.I have tried this also, but the busybox shell is unable to interpret the 0x. It still gives syntax error.I am trying a load modules using this script based on the output of this line. The script does some comparison on its output and does mknod. I am stuck here as there are around 50 insmod's to do and 50 mknod, which is very cumbersome if done manually.
neil1234
A: 
major_hex=`stat -c %t $dev 2>/dev/null`
cur_major=`printf "%2d" 0x"$major_hex"`
Peter Lyons
Hi Peter,Thanks for replying to this question.In busybox I couldn't find the support for the bc command.As all my drivers are character modules, so cannot do cat/proc/partitions for any info on them.I need to find a way where I can have major number in decimal.I am posting this comment 3rd time, as i dunno why it is not getting appended.
neil1234