Jump to content











Photo
- - - - -

[RELEASE] mbrview.g4b a BAT! tool for grub4dos


  • Please log in to reply
61 replies to this topic

#1 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 05 November 2012 - 10:29 AM

Please find attached mbrview.g4b, a simple grub4dos !BAT script to inspect the contents (partition table) of a MBR.

No instructions needed/provided, you either know where your towel is :thumbsup: or you don't :(.
(but if you run it without parameters it will give you some hints ;))

If chenall of any of the good grub4dos developers happen to read this, I adopted (temporarily) the .g4b extension, in order to easily recognize grub4dos batches, some alternatives could be :unsure::

  • .g4b ->grub4dos batch
  • .g4s ->grub4dos script
  • .bip :w00t:-> batch is possible or batch is powerful

it would be a good idea if we had an "officially" approved extension and - ideally - have it *somehow* registered in grub4dos as an executable, something like [PSEUDOCODE] :ph34r::



find batchfile || find batchfile.g4b

to avoid the need to type the extension on command line.

Release ALPHA 0.02 2012-11-05

Have fun :smiling9:, don't make systems unbootable.... :whistling:


:cheers:
Wonko

 

 

EDIT: 31 October 2013

Nando4 :worship: was so kind as to "translate" the mbrview.g4b into "wenv-less" code, making use of the features of more recent grub4dos versions, in order to easen the requirements and make it more efficient. (and with thanks to Steve6375 for a couple of vital suggestions)

Find it and it's story starting from here:

http://reboot.pro/to...b4dos/?p=179032

(and I am attaching here a copy for the lazy ;) and as a preventive measure against next code box IPB board software botching)

Attached Files



#2 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 05 November 2012 - 11:17 AM

for this to work, you should explain what grubutils are required (just wenv?) and where they need to be located - e.g. /boot/grub?
Maybe even test for wenv existence at start of script?
Also much quicker to run if you put
insmod wenv
at the start of the batch file as wenv will then be held in memory instead of loading it from the drive each time.
Also, your table border characters only work in non-graphics mode (can't use splashimage and graphicsmode commands or get garbage borders).
Nice work though and a good example of how to use batch files in grub4dos :clap:

Attached Thumbnails

  • mbrview.jpg


#3 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 05 November 2012 - 11:25 AM

re. grub4dos batch file extensions
there should be one for an executable and one for a batch file

.g4e
.g4b

???

#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 05 November 2012 - 12:16 PM

for this to work, you should explain what grubutils are required (just wenv?) and where they need to be located - e.g. /boot/grub?

Any difficult part in :dubbio::

:syntax
echo *mbrview.g4b* - grub4dos BAT! file by jaclaz
echo released under the jaclaz's CAREWARE license
echo Version 0.02 Alpha - requires WENV

and in:

No instructions needed/provided, you either know where your towel is :thumbsup: or you don't :(.
(but if you run it without parameters it will give you some hints ;))


Someone :whistling: half-@§§edly ;) translated the WENV read-me:
http://reboot.pro/14409/
and even stated on this page:
http://www.rmprepusb...rials/grubutils



Note: The default command path for grub4dos is the /boot/grub folder - it is recommended to place all your utilities in /boot/grub on your boot drive so that grub4dos can find them.
menuset 0 0 0 0 0 0 10 50 5 29 35
will run the file menuset which must exist in the /boot/grub folder.

The alternative is to path each command - e.g. use /bin/wenv instead of just wenv and place the wenv file at /bin.

... or place it in root... :whistling:



Maybe even test for wenv existence at start of script?

Sure :), next version will also make some coffee (black, strong and with two cups of sugar ;)).

Also much quicker to run if you put
insmod wenv
at the start of the batch file as wenv will then be held in memory instead of loading it from the drive each time.

Have you actually TIMED the little batch? :w00t:
It takes next to no time to execute, a faster execution would result in nearer to no time.
But thanks for the hint, maybe useful for more complex batch files :thumbup:.

Also, your table border characters only work in non-graphics mode (can't use splashimage and graphicsmode commands or get garbage borders).

Well, that's your problem :ph34r:.
They are not "my" border characters, they are "standard", "IBM" border characters, and just like .cmd's are intended to be run in a cmd window, my !BAT files are intended to work in "plain character mode". (feel free to modify /correct so that in works also in other modes)

Nice work though and a good example of how to use batch files in grub4dos :clap:

Yep, though I am struggling with the differences between the "plain" grub4dos batch commands, and the WENV ones, and with the latter I seem like I cannot avoid to echo on screen an input like:
wenv set citem=$u,$input,Choose an item:

echo you chose %citem%

which will result in (if "1 is input):

Choose an item:1citem=1
you chose 1

:dubbio: :frusty:

:cheers:
Wonko

#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 05 November 2012 - 12:30 PM

Yes, I have timed it - under QEMU it took almost a minute (using QEMU in RMprepusb running from a flash drive)! With insmod wenv at the start it takes less than a second!
To avoid echo after user input, use debug off

P.S. if you put wenv in the root it does not work unless you use /wenv instead of wenv

#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 05 November 2012 - 01:12 PM

Yes, I have timed it - under QEMU it took almost a minute (using QEMU in RMprepusb running from a flash drive)! With insmod wenv at the start it takes less than a second!
To avoid echo after user input, use debug off

P.S. if you put wenv in the root it does not work unless you use /wenv instead of wenv

That's strange :unsure:.
I am using Qemu Manager ("normally" from hard disk).
Both mbrview.g4b and wenv are in ROOT of a grub4dos floppy (image) mapped as first floppy (in the QEMU VM, not in grub4dos).
I don't use call (as in the image you posted on your site), and don't use /wenv anywhere :dubbio:
Adding a:
echo %@time%
at the beginning and end of the batch, in multiple attempts at the most it gives 1 second difference, which means that it takes less than 1 second.

This could be a good hint to use a grub4dos floppy image also on real hardware. :dubbio:

Is there an "unload" correspondent to INSMOD? :unsure:

To avoid echo after user input, use debug off

Thanks :)

:cheers:
Wonko

Attached Thumbnails

  • mbrviewg4b.jpg


#7 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 05 November 2012 - 01:43 PM

It is slow because I boot from a USB drive via QEMU to grub4dos and wenv is on the same usb drive. disk images in QEMU are much faster than external physical device access.
I just retested using wenv in the root and it does work without needing the / ! That is odd as I am sure I have tried in other similar circumstances and had to use /wenv ???

#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 05 November 2012 - 02:54 PM

Alternate test:
booted Qemu VM from a grub4dos floppy image (mapped as first floppy in the Qemu VM)
  • mapped a \Physicaldriven to second disk (of the Qemu VM)
  • mapped the grub4dosbat.ima floppy image to mem:
    
    
    
    map --mem (hd1,0)/mypath/grub4dosbat.ima (fd1)
    
    
    
    map --hook
    
    root (fd1)
    
    
  • run on command line mbrview.g4b (hd0)
same nearly instant times.

So, it seems like it is a good idea to have grub4dos batch files in a grub4dos floppy mapped to --mem, this way everything is fast (and there is not any mess anywhere in the "external" container device, and since we map to "mem" this image can even be gzipped.

:cheers:
Wonko

#9 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 05 November 2012 - 04:51 PM

...
in order to easily recognize grub4dos batches, some alternatives could be :unsure::

  • .g4b ->grub4dos batch
  • .g4s ->grub4dos script
  • .bip :w00t:-> batch is possible or batch is powerful
...

What about .g4d?

#10 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1062 posts
  •  
    Belgium

Posted 05 November 2012 - 05:00 PM

This might force grub4dos to go (back) to non-graphics mode:
terminal console


#11 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 05 November 2012 - 05:57 PM

What about .g4d?

Acronym of? :innocent:
  • .g4d -> grub4dos *anything* :unsure:
  • .g4d -> grub4dos datch file :whistling:
  • .g4d -> grub4dos dummy file :w00t:
  • .g4d -> grub4dos don't even think of touching this :ph34r:
What about .are? :dubbio:
  • .are -> a random extension
Seriously :), the point/raised issue was only about the opportunity of having an "official" extension for the !BAT files, and thus an easy way to recognize them and having grub4dos treat them as "executables", not necessarily of choosing a suitable extension, we can make a poll for this (after having made a video ;)).

:cheers:
Wonko

#12 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 02:23 PM

I don't use call (as in the image you posted on your site), and don't use /wenv anywhere

 
 

I just retested using wenv in the root and it does work without needing the / ! That is odd as I am sure I have tried in other similar circumstances and had to use /wenv ???

 

I tried with attached wenv and grub4dos-0.4.5b-2011-04-30 (chenall build) keeping grldr, wenv and mbrview.g4b on the root of the floppy.


Two observations.

 

Firstly, script doesn't run will the following error: "Warning! No such command: setlocal"

Secondly, simply invoking wenv doesn't work unless I prepend a '/', i.e. /wenv

 

Screenshot attached.

 

mbrview.png



#13 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 02:39 PM

Using a 2 yr old grub4dos is not good!  Try latest chenall featured build (just overwrite grldr file) - here  (2013-03-03  0.4.5c one is latest).



#14 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 02:43 PM

Using a 2 yr old grub4dos is not good!  Try latest chenall featured build (just overwrite grldr file) - here  (2013-03-03  0.4.5c one is latest).

 

Ahh..I forgot to tell you beforehand that wenv doesn't work (or I couldn't make it to work) with grub4dos-0.4.5c-2013-03-10



#15 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 02:48 PM

Ahh..I forgot to tell you beforehand that wenv doesn't work (or I couldn't make it to work) with grub4dos-0.4.5c-2013-03-10

 

The above mentioned one, as well as grub4dos-0.4.5c-2013-03-03grub4dos-0.4.6a-2013-03-10 returns the following error: "Error 13: Invalid or unsupported executable format"



#16 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 March 2013 - 02:54 PM

Idea :idea:

Try the batch with the LATEST grub4dos version EARLIER than 05 November 2012 (date when the batch was posted). :unsure:

 

I don't know. like grub4dos-0.4.5c-2012-10-02.7z or grub4dos-0.4.5c-2012-06-19.7z ....

 

Also, I would like to draw your attention to the fact that besides letters:

a -> Alpha

b -> Beta

c -> Final or production

 

The download page has items marked as:

Test Only <- DO NOT use them if not for tests

Featured <- this should be last version you can use "normally"

 

In other words :), you should ONLY use "c" versions and ONLY IF the have no tag or they are tagged as "Featured".

 

 

:cheers:

Wonko



#17 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 02:59 PM

grub assumes a path of /boot/grub - so if wenv is in that folder you don't need to path it...

 

P.S. only use 'featured' versions = released  - others are Beta and experimental - so 03-03 is latest featured.



#18 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:01 PM

grub assumes a path of /boot/grub - so if wenv is in that folder you don't need to path it...

 

 

 I tried with attached wenv and grub4dos-0.4.5b-2011-04-30 (chenall build) keeping grldr, wenv and mbrview.g4b on the root of the floppy.


#19 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 March 2013 - 03:02 PM

grub assumes a path of /boot/grub - so if wenv is in that folder you don't need to path it...

or if the file is in root (at least this is what was true):

http://reboot.pro/to...b4dos/?p=162726

 

But, really, I don't see a problem in adding a / in front of the command :dubbio: if needed.

 

Holmes.Sherlock, the character you took the nick from was reknown for his deductive, logical capabilities.

 

Please note how this behaviour of grub4dos (different versions behaving differently with regards to files in root) have ALREADY been explicited in this thread.

 

When using an OUTDATED version that DID NOT allow the removing of the slash you get the error, try with a more suitable version!

 

Try being as logical as the real Sherlock Holmes... ;)

 

 

:cheers:

Wonko



#20 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:06 PM

Idea :idea:

Try the batch with the LATEST grub4dos version EARLIER than 05 November 2012 (date when the batch was posted). :unsure:

 

I don't know. like grub4dos-0.4.5c-2012-10-02.7z or grub4dos-0.4.5c-2012-06-19.7z ....

 

grub4dos-0.4.5c-2012-10-02 fails once again. M y system has turned to G4D repo. Before proceeding further, I'd really like to have a word with chenall regarding how many Renminbi per Beta testing he's going to offer me.  :chair:



#21 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 March 2013 - 03:08 PM

grub4dos-0.4.5c-2012-10-02 fails once again. M y system has turned to G4D repo. Before proceeding further, I'd really like to have a word with chenall regarding how many Renminbi per Beta testing he's going to offer me.  :chair:

Yes, life is tough. :(

 

:cheers:

Wonko



#22 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:09 PM

Try being as logical as the real Sherlock Holmes... ;)

 

It was an OBSERVATION ONLY, my bearded friend, not a bug-report.



#23 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:12 PM

Yes, life is tough. :(

 

Before I give several hundred wild tries, I request either of you to try out the same on the latest version. It may happen I am doing some fundamental mistake, though chances are slim.



#24 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14093 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 March 2013 - 03:23 PM

Before I give several hundred wild tries, I request either of you to try out the same on the latest version. It may happen I am doing some fundamental mistake, though chances are slim.

Not a hundred.

Just one more.

The grub4dos I have in the floppy image on which I tested/developed the batch is grub4dos-0.4.5c-2012-06-19.7z

You know, like:

 

 

I don't know. like grub4dos-0.4.5c-2012-10-02.7z or grub4dos-0.4.5c-2012-06-19.7z ....

;)

 

Maybe it's the wenv version the issue? :unsure:

The one I have on that floppy is 27-06-2011

 

Just to confirm (just tested) that mbrview.g4b works alright with grub4dos-0.4.5c-2013-03-03.

Something else must be the issue.

 

:cheers:

Wonko



#25 steve6375

steve6375

    Platinum Member

  • Developer
  • 6688 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 03:35 PM

I used

 

wenv  21/02/2011    21/01/2011

 

worked fine with grub4dos grldr 2013-03-03 :clap:   :dubbio:

 

no need to modify to use \wenv

 

Because I used graphicsmode and a bitmap, I did need to type  graphicsmode 3 to get nice table lines.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users