Can't convert IMG to ISO - bash

So I'm currently working on my own OS (just for fun), and it's currently being compiled into an IMG file. I know it's not needed but I would like to try and compile it into an ISO, but so far I've had no luck with it. I'm not quite sure which files are needed, so just ask for them and I will edit the post :)
When I run the img I get this:
But when I run the ISO I get this:
Here's my compile script I wrote in batch:
#echo off
echo Building KronkOS floppy image!
echo.
echo Assembling bootloader...
echo ======================================================
wsl nasm -f bin bootloader/boot.asm -o bootloader/boot.bin
echo Done!
echo.
echo Assembling KronkOS kernel...
echo ======================================================
wsl nasm -f bin kernel.asm -o KERNEL.BIN -l kernel_list.lst
echo Done!
::echo.
::echo Creating elf kernel file...
::echo ======================================================
::wsl nasm -f elf32 -o kernel.o kernel.asm
::wsl ld -m elf_i386 -o kernel.elf kernel.o
::del kernel.o
::echo Done!
::echo.
::echo Assembling programs...
::echo ======================================================
::cd programs
:: for %%i in (*.BKF) do del %%i
:: for %%i in (*.ASM) do wsl nasm -O0 -f BIN %%i
:: for %%i in (*.) do ren %%i %%i.BKF
::cd ..
::echo Done!
echo.
echo Adding bootsector to disk image...
echo ======================================================
wsl mformat -f 1440 -B bootloader/boot.bin -C -i images/KronkOS.img
echo.
echo Done!
echo.
echo Copying kernel and applications to disk image...
echo ======================================================
wsl mcopy -D o -i images/KronkOS.img KERNEL.BIN ::/
wsl mcopy -D o -i images/KronkOS.img programs/*.BKF ::/
wsl mcopy -D o -i images/KronkOS.img programs/*.BAS ::/
echo.
echo Done!
echo.
echo Do you want to build and ISO?
echo ======================================================
choice /c YN
if errorlevel 1 set x=1
if errorlevel 2 set x=2
if "%x%" == "1" (
cd images
wsl genisoimage -input-charset utf-8 -o KronkISO.iso -V KRONKOS -b KronkOS.img ./
cd..
echo.
echo Done!
)
echo.
echo ======================================================
echo Build done!
choice /c YN /m "Run KronkOS build in QEMU?"
if errorlevel 1 set y=1
if errorlevel 2 set y=2
if "%y%" == "1" (
if "%1" == "-d" (
wsl sh -c "export DISPLAY=0:0 && qemu-system-x86_64 -s -S -fda images/KronkOS.img"
) else (
if "%x%" == "1" (
wsl sh -c "export DISPLAY=0:0 && qemu-system-x86_64 images/KronkISO.iso"
) else (
wsl sh -c "export DISPLAY=0:0 && qemu-system-x86_64 -fda images/KronkOS.img"
)
)
)'
cls

So I changed the tool I used to convert it into an ISO from fat_imgen to mtools.I also followed what Michael Petch suggested in a comment which was to use the -cdrom option in qemu, and now everything seems to work as it should.

Related

.bat curl with for complaining about a ( was unexpected at this time

I have the following code.
#echo off
SetLocal EnableDelayedExpansion & REM All variables are set local to this run & expanded at execution time rather than at parse time (tip: echo !output!)
REM Get full path to run.bat file (excluding filename)
set wrapper_dir=%~dp1dist
set arch=amd64.exe
set system=windows
mkdir %wrapper_dir%
REM get_my_version - Find the latest version available for download.
(for /f %%i in ('curl -f -s https://prysmaticlabs.com/releases/latest') do set my_version=%%i) || (echo [31mERROR: require an internet connection. ESC[0m && exit /b 1)
echo ESC[37mLatest release is %my_version%.ESC[0m
IF defined USE_MY_VERSION (
echo [33mdetected variable USE_MY_VERSION=%USE_MY_VERSION%[0m
set reason=as specified in USE_MY_VERSION
set my_version=%USE_MY_VERSION%
) else (
set reason=automatically selected latest available release
)
echo Using version %my_version%.
set PROGRAM_REAL=%wrapper_dir%\program-%my_version%-%system%-%arch%
if [%1]==[program-real] (
if exist %PROGRAM_REAL% (
echo ESC[32mBeacon chain is up to date.[0m
) else (
echo ESC[35mDownloading beacon chain %my_version% to %PROGRAM_REAL% %reason%[0m
for /f "delims=" %%i in ('curl --silent -w "%%{http_code}" -L "https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch%" -o "%PROGRAM_REAL%" ') do set http=%%i
if %http%=="400" (
echo ESC[35mNo program real found for %my_version%ESC[0m
exit \b 1
)
curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch%.sha256 -o %wrapper_dir%\beacon-chain-%my_version%-%system%-%arch%.sha256
curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch%.sig -o %wrapper_dir%\beacon-chain-%my_version%-%system%-%arch%.sig
)
)
At the line of the second for loop inside the IF statement(second IF statement) it complains ( was unexpected at this time.
The way to work around it , is to "grease" the batch file by running this command (on the prompt directly)
>for /f "delims=" %i in ('curl --silent -w "%{http_code}" -L https://prysmaticlabs.com/releases/beacon-chain-%prysm_version%-%system%-%arch% -o gg.txt') do set http=%i
ONLY then does it work
>prysm1.bat program-real version
A subdirectory or file C:\Users\HP\Documents\Investments\ethbox\prysm\dist already exists.
Latest release is v1.4.2.
detected variable USE_MY_VERSION=fake
Using version fake.
Downloading beacon chain fake to C:\Users\HP\Documents\Investments\ethbox\prysm\dist\program-fake-windows-amd64.exe as specified in USE_MY_VERSION
I know it has to do with the way the variables are expanded at execution vs parse time and that maybe a bracket, _ or other special characters are causing this. But i tried a couple of things and the problem persists. (all did not work)
quote the entire for with double quotes "
use brakets around the for
not using the _ in my_version.
Any ideas?
thanks
UPDATES after comments below
The script now does not complain after #aschipfl 's suggestions. However the last if stat is not evaluating to true. Made the for echo the result to ensure value in if stat.
for /f "delims=" %%i in ('curl --silent -o nul -w "%%{http_code}" https://prysmaticlabs.com/releases/beacon-chain-%version%-%system%-%arch% ') do set "http=%%i" && echo %%i
Based on all the constructive feedback, here is the final working version the summary of which :
Replacing [] with ""( quotes) in all if statements in order to protect spaces and other special characters.
Using !! vs %% for http var since it is in a block with delayed expansion
Check if download exists (404 error) then proceed and download.
#echo off
SetLocal EnableDelayedExpansion & REM All variables are set local to this run & expanded at execution time rather than at parse time (tip: echo !output!)
.... same code as above...
if "%1"=="program-real" (
if exist "%PROGRAM_REAL%" (
echo ESC[32mBeacon chain is up to date.[0m
) else (
echo ESC[35mDownloading beacon chain %my_version% to %PROGRAM_REAL% %reason%[0m
for /f "delims=" %%i in ('curl --silent -o nul -w "%%{http_code}" -L "https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch%" ') do set "http=%%i" && echo %%i
if "!http!"=="404" (
echo ESC[35mNo program real found for %my_version%ESC[0m
exit /b 1
)
curl -L https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch% -o %PROGRAM_REAL%
curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch%.sha256 -o %wrapper_dir%\beacon-chain-%my_version%-%system%-%arch%.sha256
curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%my_version%-%system%-%arch%.sig -o %wrapper_dir%\beacon-chain-%my_version%-%system%-%arch%.sig
)
)

What will be the bat script syntax to find conatiner id and stop the docker container

I have written this bat script but I am getting an error on the 3rd line.
for /f %%i in ('docker ps -qf "name=^demo-application"') do set containerId=%%i
echo %containerId%
If "%containerId%" == ""
echo "No Container running"
ELSE
docker stop %ContainerId%
docker rm -f %ContainerId%
Your if syntax is slightly off. The command has to be on the same (logical) line as the if. Also the else and the command after it has to be on the same (logical) line. Use parentheses to start a code-block (the start of a command block is syntactically treated as a valid command):
for /f %%i in ('docker ps -qf "name=^demo-application"') do set containerId=%%i
echo %containerId%
If "%containerId%" == "" (
echo "No Container running"
) ELSE (
docker stop %ContainerId%
docker rm -f %ContainerId%
)
I would do this, without having to set a variable:
for /f %%i in ('docker ps -qf "name=^demo-application"') do If not "%%i" == "" (
docker stop %%i
docker rm -f %%i
) else (
echo "No Container running"
)

Execute python via batch based on some condition?

I have a python script which it is downloading some files, before executing the task, I want to know if directory is empty or if the number of files less than 5 then run the python otherwise just say the files already exist, how can I modify the batch code in order to apply this change.
#echo off
.....
:begin
python.exe "%ScriptFolderPath%"\extractDAILYdata.py -u %UserName% -p %Password% -s %BirstSpace% -r %ATIBaseUrl% -sp %DailyLoadPath% -f "%LogPath%" -i %LogLevel% -l %LogFile%
if %errorlevel%==0 goto bcsuccess
:bcerror
echo Task "%TaskName%" failed: %date% >> "%LogPath%\%LogFile%"
exit /B %errorlevel%
:bcsuccess
echo Task "%TaskName%" succeeded: %date% >> "%LogPath%\%LogFile%"

Windows Batch file execute X files at a time

I have this code in my batch file:
#echo off
set real_parent_path=%1%
for %%F in (%real_parent_path%*.*) do call set files=%%files%% %%F
START cmd.exe /k "cd S:\Production\CrushFTP7_PC\modules\photomatixpro5 & PhotomatixCL -z -Z AA8E67A0 -x "S:\Production\CrushFTP7_PC\modules\photomatixpro5\BuiltinPresets\LCP360_settings.xmp" -mp 8 -a2 -am 12 -tr -r 11 -n 0 -ns 0 "_HDR" -bi 8 -h remove -s jpg -d %real_parent_path%HDR\\%files%"
%files% contains a list of all the files in the working folder, how would I send 3 files at a time to the START command?
Given your feedback in the comments - I might do something like the following
#echo off
setLocal enableDelayedExpansion
set real_parent_path=%1%
set count=0
set "files="
for %%F in (%real_parent_path%*.*) do (
set /a count+=1
set files=!files! %%F
if !count!==3 (
START cmd.exe /k "cd S:\Production\CrushFTP7_PC\modules\photomatixpro5 & PhotomatixCL -z -Z AA8E67A0 -x "S:\Production\CrushFTP7_PC\modules\photomatixpro5\BuiltinPresets\LCP360_settings.xmp" -mp 8 -a2 -am 12 -tr -r 11 -n 0 -ns 0 "_HDR" -bi 8 -h remove -s jpg -d %real_parent_path%HDR\\!files!"
set count=0
set "files="
)
)
Run the start command inside the for loop, every third iteration - then clear the files variable, and continue the loop.

Use cmd prompt to search a word on google or other search engine

I am trying to use a programming language to search google or another specified search engine. I would like to use windows cmd prompt to do so because the specified programming language has a simple command to access the cmd prompt.
Any ideas on how to search google from cmd prompt?
Type the following on the command-line or in the run command (Win+R) and it will open your default browser to search for SEARCHTERM using Google:
start www.google.com/search?q=SEARCHTERM
Note that you have to replace whitespaces in SEARCHTERM with pluses, e.g.
start www.google.com/search?q=Use+cmd+prompt+to+search+a+word+on+google+or+other+search+engine
Alternatively you could also put this command in a batch file:
#start www.google.com/search?q=%1+%2+%3+%4+%5+%6+%7+%8+%9
You can write in the ps1 file:
function googleSearch{start www.google.com/search?q=$args}
set-alias g googleSearch
then restart your powershell,
g whatwhatwhat
easy.
#echo off
color a
setlocal ENABLEDELAYEDEXPANSION
echo Google Batch
echo Made By GenoSans
start https://discord.gg/WwRtbBe
timeout -t 5 /nobreak
:a
cls
echo ,,
echo .g8'''bgd `7MM
echo .dP' `M MM
echo dM' ` ,pW'Wq. ,pW'Wq. .P'Ybmmm MM .gP'Ya
echo MM 6W' `Wb 6W' `Wb :MI I8 MM ,M' Yb
echo MM. `7MMF'8M M8 8M M8 WmmmP' MM 8M''''''
echo `Mb. MM YA. ,A9 YA. ,A9 8M MM YM. ,
echo `'bmmmdPY `Ybmd9' `Ybmd9' YMMMMMb .JMML.`Mbmmd'
echo 6' dP
echo Ybmmmd'
echo.
set /p s=Search:
set word=+
set str=%s%
set str=%str: =!word!%
start http://www.google.com/search?q=%str%
goto a
I created a Batch file 'g.bat' and added it to my PATH. It looks like this:
start www.google.co.uk/search?q=%1+%2+%3+%4+%5
Supports up to 5 words (of course you can add more). Now I can search from CMD or start by typing "g query"
Edit: Credit to Andreas for the inspiration
Create an alias with doskey in a .bat or .cmd file containing those lines:
#echo off
title "Foo Bar"
doskey goo=echo off $T echo Googling: $* $T start "" "www.google.com/search?q=$*" $T echo on
We add "" to launch research in the default browser.
However, if you want to goto another search engine, just change it by your browser. For instance, iexplorer for Internet explorer or firefox if you prefer Mozilla Firefox.
Example to use it :
goo stack overflow // it works !
Weakness: If you search a sentence containing & special character that will stop your research until this character.
Example :
goo stack& overflow // it does not work !
Enjoy ! =)
Note: For Linux users having Cygwin or MSYS2, you can add this function in .bashrc file to do the same routine :
goo ()
{
echo "Googling: $#";
start "" "www.google.com/search?q=$*" $#
}
Best regards !
I suppose you could use wget from the command line.
wget -U "Firefox/3.0.15" http://www.google.com/search?q=SEARCH+TERMS+HERE -O result.html -q
Or -O- -q to output to stdout. Scraping the results from the html will be a different matter entirely, though.
If you do get wget, might as well get grep as well, or just get all of GnuWin32 as it's quite useful. Then you can do stuff like this:
wget -U "Firefox/3.0.15" "http://www.google.com/search?q=wget+google+search" -O- -q 2>&1 | grep -E -o -e "<cite>[^<]+</cite>" | sed -r -e "s/<[^>]+>//g"
... to get the URL of the first link from a Google search. The sky's the limit. Get creative.
(Output of the example command above: isaksen.biz/blog/?p=470)
If you want to display the first title plus the first URL, it gets a little more complicated.
#echo off
setlocal enabledelayedexpansion
set search=%1 %2 %3 %4 %5 %6 %7 %8 %9
for /l %%a in (1,1,8) do if "!search:~-1!"==" " set search=!search:~0,-1!
set search=%search: =+%
wget -U "Firefox/3.0.15" "http://www.google.com/search?q=%search%" -O search.html -q 2>NUL
for /f "tokens=*" %%I in ('grep -P -o "<h3 class=.*?</h3>" search.html ^| sed -r -e "s/<[^>]+>//g"') do (
echo %%I
goto next
)
:next
set /p I="http://"<NUL
for /f "tokens=*" %%I in ('grep -E -o -e "<cite>[^<]+</cite>" search.html ^| sed -r -e "s/<[^>]+>//g"') do (
echo %%I
del /q search.html
goto :EOF
)
Usage: search.bat up to 9 search terms here
Example:
C:\Users\me\Desktop>search command line google
googlecl - Command line tools for the Google Data APIs - Google ...
http://goosh.org/
C:\Users\me\Desktop>
Maybe this?
#echo off
:start
cls
echo.
echo G O O G L E Web Search Version 1.1
echo.
echo Type search terms, and your internet browser will open it.
echo.
set /p Web=
start www.google.com/search?q=%Web%
goto start
Save it as .bat
and boom!
open Notepad file
type start www.google.com/
save the file with .bat extensionthen
open the batch file everytime to open Google search
no need to go to cmd prompt every time

Resources