Jump to content











Photo
- - - - -

Need help for rename a file in syslinux


Best Answer Wonko the Sane , 25 October 2014 - 10:42 AM

Are you really SURE that (once you have completed the translation) syslinux.cfg, mylinux1.cfg and mylinux2.cfg are the EXACT SAME size (in bytes)?

In (say) Windows 7, open a command prompt and do a DIR of the volume.

Are the size (in bytes) EXACTLY the same? :dubbio:

Usually when using this approach files in use are "padded" to a given size by adding excess bytes at the end (in a plain text file such as these you normally add SPACEs at the end of the file until you reach the intended size, and usually multiples of a "standard" sector or "block" of 512 bytes are used).

 

 

No, there is no "/i" switch in cat, but there is actually no *need* for it, as you actually know that what you wrote in syslinux.cfg (i.e. in mylinux1.cfg and mylinux2.cfg) is all in small letters, even if the switch would exist, it would be an unneeded complication to use it, even if it would not apply to the specific case, when you do a find/replace your scope is to "narrow" the result as much as you can, NOT to "expand" it.

 

:duff:

Wonko

Go to the full post


  • Please log in to reply
42 replies to this topic

#1 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 23 October 2014 - 03:45 AM

Hi,

I create an USB bootable with syslinux 4.06. (USB format NTFS).

I create 2 syslinux.cfg file. Their name are: syslinux.cfg and syslinux_custom.cfg

I add a menu in syslinux.cfg which allow choose default configure file. My screano is: when we choose this menu, we will boot to DOS then in DOS mode, my batch file will find syslinux.cfg on USB then rename it to syslinux_org.cfg and rename syslinux_custom.cfg to syslinux.cfg.

But I get some error when do it.

In AUTOEXEC.cmd, I add this line

for %%x in (A C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%x:\syslinux.cfg set USB=%%x:

then from it my batch will rename syslinux.cfg file from %USB% drive. But it now work.

Can someone help me?

Thanks :)

P/s: I'm so sorry for my poor English.



#2 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 23 October 2014 - 09:02 AM

Nobody can help me? :(



#3 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 23 October 2014 - 01:24 PM

Can someone help me?

Yes.

http://homepage.ntlw...no-answers.html

 

 

Nobody can help me? :(

 

No.

http://homepage.ntlw...no-answers.html

 

You are CLEARLY slipping on a chocolate covered banana (i.e. you are in the known xyx issue):

http://homepage.ntlw...red-banana.html

 

WHY do you want to load DOS to rename syslinux.cfg to syslinux_custom.cfg and viceversa, can you explain your GOAL (as opposed to the teeny tiny issue you are having with the way you think you can reach it)?

 

For the record, the files that are auto-executed on DOS booting are:

  • AUTOEXEC.BAT (and NOT AUTOEXEC.CMD)
  • CONFIG.SYS

And it is possible :unsure: that you missed the part "+++ USING AN ALTERNATE CONFIGURATION FILE +++" in :

http://git.kernel.or...ee/doc/menu.txt

 

 

:duff:

Wonko



#4 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 23 October 2014 - 03:13 PM

Yes.

http://homepage.ntlw...no-answers.html

 

 

 

No.

http://homepage.ntlw...no-answers.html

 

You are CLEARLY slipping on a chocolate covered banana (i.e. you are in the known xyx issue):

http://homepage.ntlw...red-banana.html

 

WHY do you want to load DOS to rename syslinux.cfg to syslinux_custom.cfg and viceversa, can you explain your GOAL (as opposed to the teeny tiny issue you are having with the way you think you can reach it)?

 

For the record, the files that are auto-executed on DOS booting are:

  • AUTOEXEC.BAT (and NOT AUTOEXEC.CMD)
  • CONFIG.SYS

And it is possible :unsure: that you missed the part "+++ USING AN ALTERNATE CONFIGURATION FILE +++" in :

http://git.kernel.or...ee/doc/menu.txt

 

 

:duff:

Wonko

Hi, thanks for your reply.

- I'm sorry about error typing: autoexec.bat with autoexec.cmd.

- I just want rename syslinux_custom.cfg to syslinux.cfg to syslinux load it by default for later. (and I can rename it back to syslinux_custom.cfg when needed).  If using Alternate configuration file, syslinux.cfg original will be always config then in order to using syslinux_custom.cfg, I must load it through syslinux.cfg (I'm not good at English. I hope you understand what am I saying :( )

- I tried your suggestion before I created this topic. Because my USB was format to NTFS, I'm using NTFS4DOS to detect my USB. But I don't know why it not work.

Step by step

+) Using Dos.img from allbootdisk.

+) Autoexec.bat original code (from dos6.22.img)

@echo off
MSCDEX.EXE  /D:banana /L:R

+) Using UltraISO to add NTFS4DOS.exe to dos6.22.img

+) Change Autoexec.bat code

@echo off

MSCDEX.EXE  /D:banana /L:R
NTFS4DOS.exe
for %%x in (A C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%x:\syslinux.cfg set USB=%%x:
move %USB%\syslinux.cfg  %USB%\syslinux.org
move %USB%\syslinux_custom.cfg  %USB%\syslinux.cfg
reboot

+) Computer restart, boot from usb then syslinux.cfg (was renamed from syslinux_custom.cfg) will load. But it did not work.

 

Can you tell me which step I did wrong. Thanks :)


Edited by congnt92, 23 October 2014 - 03:17 PM.


#5 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 23 October 2014 - 03:29 PM

I put some lines in my syslinux.cfg. It may help you understand why I try to load DOS mode just rename a file.

label Restart Computer
menu label ^R   Restart Computer
kernel /syslinux/Reboot.c32
MENU IMMEDIATE

label Change Language
menu label ^L   Change your default language setting
kernel /syslinux/grub.exe
APPEND --config-file=/lang.lst
MENU IMMEDIATE

and Lang.lst

find --set-root /syslinux/dos.img && set dos=/syslinux/dos.img
map --mem %dos% (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

after load to DOS, autoexec.bat will:

+ run NTFS4DOS to detect my USB that format to NTFS

+ Find where syslinux.cfg locate

+ rename syslinux.cfg original file (English) to syslinux.org

+ rename syslinux_custom.cfg (My custom language) to syslinux.org

+ reboot to apply change.


Edited by congnt92, 23 October 2014 - 03:32 PM.


#6 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 23 October 2014 - 04:43 PM

Hmmm. :dubbio:

I would have thought that the MOVE command would MOVE a file to another (different) location, whilst the RENAME command would have been used to RENAME a file leaving it in the same place.

http://www.computerh...com/movehlp.htm

http://www.computerh...om/renamehl.htm

 

I believe that you wrote the batch WITHOUT BEFORE testing the commands on command line :unsure: (which is obviously recommended).

 

Still, it makes little sense to boot to Syslinux to boot to grub4dos to boot to DOS to load NTFS4DOS (which BTW normally needs a key press to load) just to rename a file.

 

You might want to shorten your "chain" by simply booting grub4dos or (if for whatever reasons you really-really *need* Syslinux) boot from it the grub4dos and use dd or cat to alter the contents of syslinux.cfg.

 

More generally (though of course you posted only PARTIAL data i.e. only your intended syslinux.cfg, possibly only a part of it and NOT the syslinux_custom.cfg, it seems like the action is NOT reversible, i.e. you boot ONCE to the initial syslinux.cfg, then your ONLY choice (short of rebooting) is to change language, and from then on, you have the syslinux_custom.cfg (renamed to syslinux.cfg).

Unless you add to this latter a way to reverse the situation, but then this could be the "main" menu. :unsure:

 

 

:duff:

Wonko



#7 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 12:35 AM

Hi,

Hmmm. :dubbio:
I would have thought that the MOVE command would MOVE a file to another (different) location, whilst the RENAME command would have been used to RENAME a file leaving it in the same place.
http://www.computerh...com/movehlp.htm
http://www.computerh...om/renamehl.htm

I believe that you wrote the batch WITHOUT BEFORE testing the commands on command line :unsure: (which is obviously recommended).

No, I'm not. I tested my command from windows 7 and it work fine.

But when I post here, I made a big mistake. It should be

move %usb%\syslinux.cfg %usb%\syslinux.org    Just simply change .cfg extension to .org

and then

move %usb%\syslinux_custom.cfg %usb%\syslinux.cfg

But you're right. Let's make it easy. Just rename needed, don't need to change file extension.

 

Still, it makes little sense to boot to Syslinux to boot to grub4dos to boot to DOS to load NTFS4DOS (which BTW normally needs a key press to load) just to rename a file.


You might want to shorten your "chain" by simply booting grub4dos or (if for whatever reasons you really-really *need* Syslinux) boot from it the grub4dos and use dd or cat to alter the contents of syslinux.cfg.


My USB use syslinux. Not Grub4dos. But I add grub.exe file to chainload when needed. I use lang.lst to load Dos.img. Of course, syslinux can load dos.img but I'm new with syslinux, so I don't know which must be type.

label Change Language
menu label ^L   Change your default language setting
kernel /syslinux/grub.exe --config-file="find --set-root /syslinux/dos.img && set dos=/syslinux/dos.img;map --mem %dos% (fd0);map --hook;chainloader (fd0)+1;rootnoverify (fd0);map --floppies=1"
MENU IMMEDIATE

If the line that I type in above is right, It make the line of command look too long. So, I use lang.lst to reduce some characters.

You boot ONCE to the initial syslinux.cfg, then your ONLY choice (short of rebooting) is to change language, and from then on, you have the syslinux_custom.cfg (renamed to syslinux.cfg).

Unless you add to this latter a way to reverse the situation, but then this could be the "main" menu. :unsure:
:duff:
Wonko


No. It's simply an option and no more. I don't boot one to syslinux with syslinux.cfg (Englsih) just only change language to custom language. If I need that, I will make only one syslinux.cfg with my custom language. In my case, I want to create USB boot with syslinux that have 2 language options.
Of course I can use

label Change Language
menu label ^L  Change your default language setting
kernel /syslinux/menu.c32
APPEND /syslinux_custom.cfg

Then we just need choose this lable to change language. But it only change our lang when we choice it. I want to take change forever until we choose Change Language label to back original langugage (In my case is English). To do this, I must rename syslinux.cfg to syslinux.org and rename syslinux_custom.cfg (with custom language) to syslinux.cfg to syslinux config it by default. And no way to rename a file when boot with syslinux. So I must boot to Dos and from here .bat files will do the rest.


Edited by congnt92, 24 October 2014 - 01:04 AM.


#8 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 08:46 AM

Hi,

I'm got it. Autoexec.bat is work fine now. But I still have a quetion.

+) Code of original autoexec.bat and config.sys (From DOS 7.1 img)

 

Autoexec.bat

@ECHO OFF
PROMPT $P$G
PATH=A:\;..
LFNFOR ON
SET DIRCMD=/4
MODE CON RATE=32 DELAY=1
LH KILLER
LH SHSUCDX /D:IDE-CD /Q /~+
LH DOSKEY
LH DOSLFN
ECHO.
ECHO Now you are in MS-DOS 7.10 prompt.
ECHO.

config.sys

DOS=HIGH,UMB
DEVICE=HIMEM.SYS
REM DEVICE=EMM386.EXE NOEMS
DEVICEHIGH=VIDE-CDD.SYS /D:IDE-CD
COUNTRY=001,437,COUNTRY.SYS
SHELL=COMMAND.COM /P /E:640
FILES=30
FCBSHIGH=4,0
BUFFERSHIGH=20
LASTDRIVEHIGH=26
STACKSHIGH=9,256
SET TEMP=.
SET TMP=.
REM MS-DOS 7.10 Boot Disk

My question is "which lines can be remove to reduce time to load in  DOS?". I just need load to DOS to rename a file. So I don't want to load some "drivers" (I call "driver" and I hope that's right :D, my knowledge about DOS is very limited).

I just want load to DOS as quickly as possible then my autoexec.bat will run immediately.

 

+) Rename command in DOS always be success? Example, syslinux.cfg on USB set hidden, system file, readonly. I can use rename command or use attrib command first to reset defaul for syslinux.cfg and then use rename command.

 

+) As I know, lowercase in DOS always become uppercase.I must change below command to what if syslinux.cfg is SYSLINUX.CFG or syslinux.CFG, (etc). I should use /i parametter for if command?

for %%x in (A C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%x:\syslinux.cfg set USB=%%x:

should be

for %%x in (A C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if /i exist %%x:\syslinux.cfg set USB=%%x:

Thanks :)


Edited by congnt92, 24 October 2014 - 08:51 AM.


#9 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 October 2014 - 09:45 AM

For the record, when you change a file extension you are anyway RENaming a file.
A filename in DOS is 8.3, and is made of name.extension, the filename is the whole thing.


Well, not really (about CaSe SeNsITivEnEsS), DOS is case unsensitive, as well as Windows generally, other OS (Linux and grub4dos, but I believe also syslinux may be so) but it depends also on the Filesystem, on CDFS and EXT2/3/4 even grub4dos is CaSe SeNsItIVe, but no, you need NOT to add the /i switch.

For what you need you can have a completely blank AUTOEXEC.BAT (to which you add your commands) and can remove everything from CONFIG.SYS, except maybe the first two lines (this depends on what NTFS4DOS needs. (please take note that using the filename "syslinux_custom.cfg" is foolish, as DOS names are and should be 8.3 and by using a non 8.3 filename you actually need to load the DOSLFN driver, which is an additional point of possible failure, use - say - "my_linux.cfg" instead)

But it is easy to test.
Simply rename CONFIG.SYS to CONFIG.TMP and AUTOEXC.BAT to AUTOEXEC.OLD, then create a new AUTOEXEC.BAT with just the commands that you want to use and test it.

To do this, I must rename syslinux.cfg to syslinux.org and rename syslinux_custom.cfg (with custom language) to syslinux.cfg to syslinux config it by default. And no way to rename a file when boot with syslinux. So I must boot to Dos and from here .bat files will do the rest.


You are still in the XYZ fallacy. :(

I will type this slowly :).
  • It is NOT NEEDED to "rename" a file, the same result can be obtained by changing the CONTENTS of the Syslinux.cfg file.
  • It is NOT NEEDED, in order to change the contents of a file, to boot to DOS (and additionally have to load NTFS4DOS) as this can be achieved rather easily through grub4dos.
Your plan (not "wrong", but unneededly complex):
Syslinux->grub4dos->DOS->NTFS4DOS->rename files

The suggested plan:
Syslinux->grub4dos->change contents of a file through a grub4dos batch or menu.lst

It would be:

  • simpler
  • faster
  • less prone to issues
JFYI:
http://en.wikipedia....i/Occam's_razor
and:
http://en.wikipedia..../KISS_principle


:duff:
Wonko
  • imnothing likes this

#10 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 11:22 AM

Well, not really (about CaSe SeNsITivEnEsS), DOS is case unsensitive, as well as Windows generally, other OS (Linux and grub4dos, but I believe also syslinux may be so) but it depends also on the Filesystem, on CDFS and EXT2/3/4 even grub4dos is CaSe SeNsItIVe, but no, you need NOT to add the /i switch.
 
For what you need you can have a completely blank AUTOEXEC.BAT (to which you add your commands) and can remove everything from CONFIG.SYS, except maybe the first two lines (this depends on what NTFS4DOS needs. (please take note that using the filename "syslinux_custom.cfg" is foolish, as DOS names are and should be 8.3 and by using a non 8.3 filename you actually need to load the DOSLFN driver, which is an additional point of possible failure, use - say - "my_linux.cfg" instead)
 
But it is easy to test.
Simply rename CONFIG.SYS to CONFIG.TMP and AUTOEXC.BAT to AUTOEXEC.OLD, then create a new AUTOEXEC.BAT with just the commands that you want to use and test it.
 

 
You are still in the XYZ fallacy. :(
 
I will type this slowly :).

  • It is NOT NEEDED to "rename" a file, the same result can be obtained by changing the CONTENTS of the Syslinux.cfg file.
  • It is NOT NEEDED, in order to change the contents of a file, to boot to DOS (and additionally have to load NTFS4DOS) as this can be achieved rather easily through grub4dos.

Your plan (not "wrong", but unneededly complex):
Syslinux->grub4dos->DOS->NTFS4DOS->rename files
 
The suggested plan:
Syslinux->grub4dos->change contents of a file through a grub4dos batch or menu.lst
 
It would be:
 
 

  1. simpler
  2. faster
  3. less prone to issues

JFYI:

http://en.wikipedia....i/Occam's_razor

and:

http://en.wikipedia..../KISS_principle

 
 
:duff:
Wonko

 

Thanks for your suggestion Wonko. Patch a file using grub4dos (cat command) is not easy to you. I'll try to learn more.

Following your suggestion, I'll try and report.



#11 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 October 2014 - 11:39 AM

Thanks for your suggestion Wonko. Patch a file using grub4dos (cat command) is not easy to you. I'll try to learn more.
Following your suggestion, I'll try and report.

Well, you can use dd fine instead.
 
Imagine that you have THREE files:
  • syslinux.cfg (sized - say - 2048 bytes or however larger than the lower size limit for a file to exit the internal $MFT storage on NTFS)
  • my1linux.cfg (the exact same size of the above)
  • my2linux.cfg (the exact same size of the above) 
What do you think will happen if in grub4dos you execute:
dd if=/my1linux.cfg of=/syslinux.cfg
or
dd if=/my2linux.cfg of=/syslinux.cfg
:whistling:
 
:duff:
Wonko
  • imnothing likes this

#12 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 12:47 PM

Well, you can use dd fine instead.
 
Imagine that you have THREE files:

  • syslinux.cfg (sized - say - 2048 bytes or however larger than the lower size limit for a file to exit the internal $MFT storage on NTFS)
  • my1linux.cfg (the exact same size of the above)
  • my2linux.cfg (the exact same size of the above) 
What do you think will happen if in grub4dos you execute:
dd if=/my1linux.cfg of=/syslinux.cfg
or
dd if=/my2linux.cfg of=/syslinux.cfg
:whistling:
 
:duff:
Wonko

 

Sound good to me. But:

 

First stupid question. I don't know why I get error 11 when type above lines after grub.exe promt.

Here a part of my syslinux.cfg file

label change lang
kernel /N.TC/Boot/grub.exe
APPEND --config-file="dd if=/mylinux1.cfg of=/syslinux.cfg"

Or you can tell me how to make a small .lst file which content these lines? Then I can use it for another case later (by grub4dos or chainload from syslinux). It's will be a helpful example for me to learn :)

 

Second stupid question. DD command in grub4dos like rename in DOS ? If that's right, so what happen with original syslinux.cfg. mylinux.cfg will be renamed to syslinux.cfg and original syslinux.cfg will be overwrite?

 

Finally, I'm new for grub4dos, syslinux and DOS and I want to try to learn more. So if I have a stupid question, I hope it will not make uneasy to you :D.


Edited by congnt92, 24 October 2014 - 12:51 PM.


#13 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 October 2014 - 01:58 PM

dd is roughly as old as the time the sun began to rise in the morning :w00t:

though it's name, which is the short form of copy and convert is not exctly self-explaining  :frusty: , see:

http://reboot.pro/to...uest-for-ddexe/

is a very handy tool that in it's most basic form simply copies bytes from a source if or InFile to a target of OutFile.

It was originated in the *nix world where *everything* is a file, so it can deal with block devices as well.

 

So, dd if=/mylinux1.cfg of=/syslinux.cfg simply writes, byte-by-byte the contents of mylinux1.cfg to syslinux.cfg, or, given that both the source and target files are exactly the same size, after you have run the command syslinux.cfg will become EXACTLY the same as mylinux1.cfg.

When you dd if=/mylinux2.cfg of=/syslinux.cfg syslinux.cfg will become EXACTLY the same as mylinux2.cfg.

If you have two "my" config files, the syslinux.cfg will be EXACTLY the same as either of them, but of course you can have a "backup" copy of the original and re-dd it any time.

 

Since more or less you want to have two (or more choices) I would be better IMHO to have only one choice in the various Syslinux .cfg's which would be something like "change Syslinux.cfg" pointing to a grub4dos menu.lst where you can choose between the two (or more) options:

  1. Copy mylinux1.cfg contents to Syslinux.cfg (or "Change language to English")
  2. Copy mylinux2.cfg contents to Syslinux.cfg (or "Change language to Vietnamese")

A suitable menu.lst could be something *like*

 

color blue/green yellow/red white/magenta white/magenta
timeout 30

 

title Copy mylinux1.cfg contents to Syslinux.cfg

find --set-root /syslinux.cfg

dd if=/mylinux1.cfg of=/syslinux.cfg

chainloader /syslinux.bin

 

title Copy mylinux2.cfg contents to Syslinux.cfg

find --set-root /syslinux.cfg

dd if=/mylinux2.cfg of=/syslinux.cfg

chainloader /syslinux.bin

 

 

Of course given that syslinux.cfg, mylinux1.cfg, mylinux2.cfg and syslinux.bin are all in the root of the same device.

See also:

http://www.rmprepusb...inload-syslinux

to understand the usage of syslinux.bin in this context (basically you avoid re-booting as you simply pass control from grub4dos to syslinux).

There was an attempt to have ldlinux.sys to be directly chainloaded by grub4dos but cannot say if it ever reached usability.

 

As ALWAYS, you NEVER try writing something without first having tested it thoroughly on command line.

In other words, instead or trying to load grub.exe with a config file, you should FIRST just load the grub4dos and test the commands on command line.

 

You should always additionally be very sure of the paths used in grub4dos commands.

/syslinux.cfg means ()/syslinux.cfg , i.e. (<current root>)/syslinux.cfg

When on the grub4dos command line if you issue a 





root

command you will know what is <current root>

 

You will need some time here:

http://diddy.boot-la...os/Grub4dos.htm

particularly on:

http://diddy.boot-la...iles/syntax.htm

http://diddy.boot-la...iles/basics.htm

http://diddy.boot-la...s/files/cli.htm

 

Make sure to use a decently recent grub4dos version.

 

:duff:

Wonko



#14 betrand

betrand

    Frequent Member

  • Advanced user
  • 467 posts
  •  
    France

Posted 24 October 2014 - 02:14 PM

Or...

Why don't you cat -hex --replace the name of the file in the rootdir. As in Steve's topic Bootfix.bin grldr "Press any key" (Can't link, the link system buggered (either on my computer, or generally)).



#15 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 October 2014 - 02:53 PM

Or...

Why don't you cat -hex --replace the name of the file in the rootdir. As in Steve's topic Bootfix.bin grldr "Press any key" (Can't link, the link system buggered (either on my computer, or generally)).

The topic is here (and the "link system" works fine: http://reboot.pro/to...any-key-prompt/ )

 

Though what is cat ---hex replaced  is a file name in the .iso (or CD/DVD) no-emulation bootsector, nothing in the "rootdir".

 

On NTFS you could cat --hex the $MFT entry, maybe. :ph34r:

 

Or if ldlinux.bin had not a self-check checksum (which I seem to remember it actually has) you could hex replace the syslinux.cfg string in the ldlinux.bin.

 

Still one could use a "base" syslinux.cfg with a single choice like:

 

LABEL othermenu
MENU LABEL Another Menu
KERNEL menu.c32
APPEND othermenu.conf

 

 

and cat --hex replace the "othermenu.conf" with either mymenu001.conf or mymenu002.conf in the  syslinux.cfg file (which brings us back nicely to the initially suggested):

 

And it is possible  :unsure: that you missed the part "+++ USING AN ALTERNATE CONFIGURATION FILE +++" in :

http://git.kernel.or...ee/doc/menu.txt

 

 

 

:duff:

Wonko



#16 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 03:59 PM

A suitable menu.lst could be something *like*

....

 

:duff:

Wonko

 

Follow your type in menu.lst, I don't know why still get error 11: Unrecognized device string, or you omitted the required DEVICE part which should lead the file name.


Edited by congnt92, 24 October 2014 - 04:00 PM.


#17 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 04:12 PM

Or...

Why don't you cat -hex --replace the name of the file in the rootdir. As in Steve's topic Bootfix.bin grldr "Press any key" (Can't link, the link system buggered (either on my computer, or generally)).

 Your suggestion same with Wonko's suggestion. And I'll try to learn about cat-hex.

I'm newbie and I just want start from simplest thing :D. From load to DOS to rename syslinux.cfg file and now, I'm try to learn about dd command that Wonko show. Anw, thanks for your visit and leave me a suggestion :) If it's possible, I'll be gratified with your help.

 

And, in order to have 2 syslinux.cfg file which content 2 languages is quite easy. Just creat syslinux_custom.cfg and then use syslinux.cfg load it. (By USING AN ALTERNATE CONFIGURATION FILE or "kernel /menu.c32 ;APPEND /Syslinux_custom.cfg").

In my case, not only change language, I want to make the language which selected from menu take by default for using later. That's reason why I try to rename it instead of load it from original syslinux.cfg.



#18 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 October 2014 - 04:12 PM

Follow your type in menu.lst, I don't know why still get error 11: Unrecognized device string, or you omitted the required DEVICE part which should lead the file name.

Is there a particularly difficult part in "*like*" or  "TRY COMMANDS ON COMMAND LINE BEFORE EVEN THINKING OF WRITING THEM IN A BATCH (or menu.lst)"?

 

I don't know (among many other things ;)):

  1. how you setup your whatever device
  2. which device is it
  3. where you put the files
  4. how the files are named
  5. which version of grub4dos you are using
  6. which version of syslinux you are using
  7. the actual SIZE of the files involved <- this is due to a particularity of NTFS
  8. the EXACT contents of ALL files involved
  9. ....

 

HOW THE HECK do you expect me to provide something that actually works in your UNKNOWN setup? :frusty:

 

I am providing you some ideas/hints/examples that you have to experiment with and adapt to your situation OR you must §@ç#ing provide the missing info, and maybe I can then help you specifically. 

 

:duff:

Wonko



#19 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 24 October 2014 - 04:23 PM

HOW THE HECK do you expect me to provide something that actually works in your UNKNOWN setup? :frusty:
 

I'm sorry. Here fully information about my "UNKNOWN setup".
+) Create USB boot with syslinux 4.06.
+) USB was format NTFS
+) size of my original syslinux.cfg is 4k. same with syslinux_custom.cfg. (duplicate original syslinux.cfg >> same code, just change title from English to my language).
+) my USB using syslinux to boot. I just use grub.exe from grub4dos-0.4.6a-2014-01-17 to chainload when needed.
+) my screano: add my language by adding label "change language setting" to syslinux.cfg. If I want to use English by default, I do nothing. If I want to use my language for USB syslinux boot, I choose this label and syslinux_custom will be original syslinux.cfg to load default for later booting.
+) Follow your guide, I got it by using syslinux >> dos >> autoexec.bat rename >> reload USB.
+) Now, follw your new suggestion, I want to try "dd" command but it not work fine :(
+) root of USB:

- syslinux.bin

- syslinux.cfg

- mylinux1.cfg

- syslinux folder content:

1) (menu folder _ which content others .cfg file: antivirus, setup windows, ...)

2) grub.exe, some .c32 file, ldlinux.sys, isolinux.bin, syslinux.exe, my custom background, bootmgr, ...


Edited by congnt92, 24 October 2014 - 04:33 PM.


#20 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 October 2014 - 05:36 PM

So, you boot to grub4dos (WITHOUT loading any menu.lst) and you are then at the Command prompt grub&gt;

What happens if you type in it:


root
and press [ENTER]

what happens if you type:


find --set-root /syslinux.cfg
[ENTER]
and then you type in it again


root
[ENTER]

the result should normally be in both cases (hd0,0), if it is, try issuing:


dd if=()/mylinux1.cfg of=()/syslinux.cfg
What happens?

IF you get something *like*:

Quote
Quote
buf_size=0x100000, loops=0x1 , in_pos=0x0, out_pos=0x0
0000000
Bytes read / written = 0xA2 / 0xA2

you managed to dd the mylinux1.cfg contents over the syslinux.cfg.

Then try issuing:


chainloader /syslinux.bin
[ENTER]


boot
[ENTER]

What happens?

Regarding the "alternate" config file, if you have in "sylinux.cfg a very short timeout, let's say TIMEOUT 1, it should pass command to the alternate .cfg so fast that it will seem like the alternate .cfg is the actual "main" .cfg.

To recap:
syslinux.cfg
contains:

Quote
TIMEOUT 1
DEFAULT othermenu
LABEL othermenu
MENU LABEL Another Menu
KERNEL menu.c32
APPEND mylinux1.cfg

or:

Quote
TIMEOUT 1
DEFAULT othermenu
LABEL othermenu
CONFIG mylinux1.cfg

Then you have your two .cfg's mylinux1.cfg and mylinux2.cfg and you do (AGAIN TRY ON COMMAND LINE FIRST):



cat /syslinux.cfg
cat --locate=mylinux1 --replace=mylinux2 /syslinux.cfg
cat /syslinux.cfg
What happens to the contents of syslinux.cfg?

:duff:
Wonko
  • imnothing likes this

#21 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 25 October 2014 - 02:19 AM

Hi, Wonko.
It work like a charm. Big big thanks to you, Wonko .
The first menu.lst file that you give me not work for me. I got error 11 message.

color blue/green yellow/red white/magenta white/magenta
timeout 30

title Copy mylinux1.cfg contents to Syslinux.cfg
find --set-root /syslinux.cfg
dd if=/mylinux1.cfg of=/syslinux.cfg
chainloader /syslinux.bin

title Copy mylinux2.cfg contents to Syslinux.cfg
find --set-root /syslinux.cfg
dd if=/mylinux2.cfg of=/syslinux.cfg
chainloader /syslinux.bin


But

The second menu.lst file work fine.

title Copy mylinux1.cfg contents to Syslinux.cfg
find --set-root /syslinux.cfg
dd if=()/mylinux1.cfg of=()/syslinux.cfg
chainloader /syslinux.bin

The bracket made difference.

So, now I have 2 ways to rename a file when booting grub4dos (or syslinux, must be chainload to grub4dos)
+) load to DOS, find syslinux.cfg locate and rename it.
And, the second way, not new for you, for others but it's new, it's something great for me.
+) using dd command.

 

  • simpler
  • faster
  • less prone to issues

 


And, I must be pleasure with this result to set a language by default. But, I'll try to work with "cat" command.
Learn, learn more, learn forever.


Edited by congnt92, 25 October 2014 - 02:22 AM.


#22 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 25 October 2014 - 04:27 AM

Hi,
DD command work fine but now I have small issue with it.
Default syslinux.cfg: English (it has a label: change your language setting which change english to my lang).
Mylinux1.cfg: my lang (it has a label: change your language setting which change my lang to english)
Mylinux2.cfg: English (dupplicate default syslinux.cfg, just rename it to Mulinux2.cfg to convert my lang back to english when needed, nothing change)

When boot from usb, default syslinux.cfg load, display language is English. I choose label: change your lang setting and it work but not completely. Almost lines in mylinux1.cfg was move to syslinux.cfg exept 2 last lines in mylinux1.cfg. But I only get this error when change from Eng >> my lang. After my lang load, even if my lang not load completely ( 2 last lines not availble in syslinux.cfg after using dd) I choose label that convert my lang >> Eng, it work very fine.

Mylinux1.cfg ( 4 last lines of file)

LABEL abcxyz (sorry, I don't type my lang in here. It could make difficult to you for understanding)
MENU LABEL abcxyz
MENU disable
MENU INDENT 6

after use dd command,almost lines of mylinux1.cfg was converted to syslinux.cfg but 4 last lines was not converted completely (Just 2 lines was converted)

LABEL abcxyz (sorry, I don't type my lang in here. It could make difficult to you for understanding)
MENU LABEL abcxyz
Menu (this line from mylinux.cfg is "menu disable" but after convert, it's only "Menu", not "disable" in here)
#this line was not convert

P/S:
All of .cfg file was create by dupplicate. I created syslinux.cfg file (English), duplicate it and rename to Mylinux2.cfg (English) and duplicate Mylinux2.cfg, rename it to Mylinux1.cfg, then only translate title of menu from English to My lang. No code was changed, even location of the code line was not changed (With same label, in all of mylinux1.cfg, mylinux2.cfg and syslinux.cfg was located with same row number _ seen from notepad++).


Edited by congnt92, 25 October 2014 - 04:33 AM.


#23 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 25 October 2014 - 08:23 AM

Report about using cat command.
cat command work fine with lowercase.
If in syslinux.cfg using

APPEND mylinux1.cfg

then cat command must be

cat --locate=mylinux1 --replace=mylinux2 /syslinux.cfg

If using

cat --locate=MYLINUX1 --replace=MYLINUX2 /syslinux.cfg

we will not get error when run cat commad BUT nothing changed in syslinux.cfg file.

So, with cat command, is there /i parameter like DOS to bypass checking of uppercase or lowercase ? (Ex. DOS command: find /i). If grub does't have /i parameter, so we should using number instead letter to avoid "upper" and "lower" comparison.

And, if I want to check the existence of mylinux1.cfg (mylinux2.cfg) then if these file is not exist, grub will not run cat command and it will display a message instead, like

The second language configuration file cannot be found on your USB drive.
Your language setting will not be changed.
Press any key to return to main boot menu.

Edited by congnt92, 25 October 2014 - 08:32 AM.


#24 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 25 October 2014 - 10:42 AM   Best Answer

Are you really SURE that (once you have completed the translation) syslinux.cfg, mylinux1.cfg and mylinux2.cfg are the EXACT SAME size (in bytes)?

In (say) Windows 7, open a command prompt and do a DIR of the volume.

Are the size (in bytes) EXACTLY the same? :dubbio:

Usually when using this approach files in use are "padded" to a given size by adding excess bytes at the end (in a plain text file such as these you normally add SPACEs at the end of the file until you reach the intended size, and usually multiples of a "standard" sector or "block" of 512 bytes are used).

 

 

No, there is no "/i" switch in cat, but there is actually no *need* for it, as you actually know that what you wrote in syslinux.cfg (i.e. in mylinux1.cfg and mylinux2.cfg) is all in small letters, even if the switch would exist, it would be an unneeded complication to use it, even if it would not apply to the specific case, when you do a find/replace your scope is to "narrow" the result as much as you can, NOT to "expand" it.

 

:duff:

Wonko


  • imnothing likes this

#25 imnothing

imnothing

    Member

  • Members
  • 37 posts
  •  
    Vietnam

Posted 25 October 2014 - 11:59 AM

Many thanks to you, Wonko.
So, what about my question above? How to add checking existence of mylinux1.cfg and mylinux2.cfg progress before grub luanch dd or cat command?
I use these line but after check the existence of custom cfg file, I don't know why it not work when type it to grub.exe command line.
if not exist /mylinux1.cfg echo abcxyz && pause chainloader /syslinux.bin
if not exist /mylinux2.cfg echo abcxyz && pause && chainloader /syslinux.bin
find --set-root /syslinux.cfg
dd if=()/mylinux2.cfg of=()/syslinux.cfg
chainloader /syslinux.bin
boot
P/s: If I want to display 3 lines with echo command so how to I do that?

thanks

Edited by congnt92, 25 October 2014 - 12:56 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users