3

I have the command below in a windows batch file, whenever I run the above batch (ipconfig.bat) to get the ip of my linux vm, it outputs the ip fine but doesn't ends the batch file, I have to press control + c and then press "y" to end the batch file. Even after adding @exit it doesn't exits.

VBoxManage --nologo guestcontrol execute "nixvm" "/root/scripts/ipconfig.sh" --username root --password mypassword --verbose --wait-for stdout @exit

Any suggestions ?

The Bash Script (which gets executed by a windows batch file)

#!/bin/bash
echo "IP Address of "LinuxVM"
ifconfig eth0 | egrep '(inet addr|RX bytes|TX bytes)'
sleep 1s
#echo "MySQL Service Status"
service mysql status
chkconfig mysql --list
sleep 1s
#echo "Displaying MySQL DBs"
mysqlshow -uroot -pmypassword

Windows Batch File

VBoxManage --nologo guestcontrol execute "LinuxVM" "/root/scripts/ipconfig.sh" --username root --password password --verbose --wait-for stdout
7
  • Using VB 4.0.0 r69151 (with the latest guest additions installed) when I run the above command I get VBoxManage.exe: The file '@exit' was not found on guest. If I remove the @exit it runs as expected. Can you post your ipconfig.sh script ?
    – user9517
    Jan 22, 2011 at 13:48
  • Hi Iain, Thanks again for your support, the command runs fine and I get the desired output, but the batch file won't exit and it waits for my input to end it by pressing ctrl + c - the ipconfig.sh which is in /root/scripts/ipconfig.sh only has ifconfig after the bin/bash. Basically, I want the command to run in a batch file via windows machine as it executes the script inside a linux vm and displays the output, it should END then instead of user input. Would you knwo the way to end this batch file ? Thanks Again !
    – Mutahir
    Jan 24, 2011 at 7:57
  • 1
    @rihatum: Does the script complete ? When my test script completes I get a status line Exit code=0 (Status=2 [successfully terminated], Flags=0) and then I get the cmd prompt back again.
    – user9517
    Jan 24, 2011 at 9:35
  • The output I posted above is what vboxmanage prints after the bash script completes. If you're not seeing an Exit ... message then it's possible your bash script isn't completing.
    – user9517
    Jan 24, 2011 at 10:32
  • 1
    This looks like a problem with Vbox 4.0.2 I just upgraded my working 4.0.0 and now I see the same problem as you.
    – user9517
    Jan 24, 2011 at 13:38

1 Answer 1

2

You can use --timeout to supply a time out in milliseconds which tells VBoxManage how long to wait for the script to exit.

VBoxManage --nologo guestcontrol execute "nixvm" "/root/scripts/ipconfig.sh" --username root --password mypassword --verbose --timeout 10000 --wait-for stdout
1
  • Hi Iain, Thank you so much, I didn't knew the timeout option for batch files as I am very new to scripting / batch stuff...just learning. But you have been a VirtualBox Virtual teacher for me :-) I am grateful for your assistance with my previous posts too. this worked and yes that's what I had thought as well (because it was working fine in previous version 4.x) but I wasn't sure - now you have just said so and I have tested it today too, it seems to be a problem. but timeout has sorted this one out. Have a good day ahead!! - Kind Regards
    – Mutahir
    Jan 24, 2011 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .