Script doesn't work, need help

view full story

http://forums.opensuse.org – Hi everyone. I'm not much experienced with scripting, but did try to write a simple one, without luck yet. So here is the story. I'm trying run a virtualbox guest os on startup. However it doesn't start because of some wiered network bridge problem. But I've found out, that if I open VirtualBox and apply again the current active nic, it does start. For some strange reason the nic name is changing almost every time on boot up. So what I'm trying to do with my script it is: find out the currently active nic name, for instance eth21, apply this settings to the VB guest machine and fire it up. Here is my script Code: #!/bin/sh sleep 60 date  >> xp_started str1=$(ifconfig |grep eth) spacepos=$(echo `expr index "$str" " "`) str2=${str1:0:$spacepos} VBoxManage modifyvm xp --bridgeadapter1 $str2 VBoxManage startvm xp --type headless If I execute each of the command in the terminal it looks ok, however running the script via sh -x scriptname tells me that spacepos equals to 0 and therfore it can not proceed to copy the string in next command. Please help, thanks (Distributions)