iPXE discussion forum
starting script from command line - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: starting script from command line (/showthread.php?tid=6772)



starting script from command line - mrc333777 - 2012-12-04 01:34

does ipxe let you run scripts from the default prompt when i press ctrl-b?
if so i cant get it to work when i type helloworld.bat which contains

helloworld.bat

#!ipxe

:loop
echo Hello world
goto loop


RE: ipxe - thomil - 2012-12-04 18:26

Yes you can do that. Simply start the script as you would start a kernel:

dhcp
kernel http://<server>/helloworld.bat
boot

or shorter:

dhcp
chain http://<server>/helloworld.bat

You may want to take a look at http://ipxe.org/docs


RE: ipxe - mrc333777 - 2012-12-06 15:15

im curious, i see alot of people talking about their scripts, is this how they are running their scripts? the same way explained below?


(2012-12-04 18:26)meteger Wrote:  Yes you can do that. Simply start the script as you would start a kernel:

dhcp
kernel http://<server>/helloworld.bat
boot

or shorter:

dhcp
chain http://<server>/helloworld.bat

You may want to take a look at http://ipxe.org/docs



RE: starting script from command line - MultimediaMan - 2012-12-06 17:53

Yes, or they embed them in the ipxe binary (undionly.kpxe/ipxe.pxe or ipxe.lkrn).

For the first time users, it would be safe to say that the CTRL-B command line is where you get your feet wet, but past that, it's all scripts on a webserver or a PHP engine.

That's the beauty of iPXE; you can compile a small embedded script which executes a certain repeatable process as specific or as general as you want; once that process is established, you can expand or leverage it further as you see fit.

Myself, I have an embedded script which attempt to dhcp (three times) and checks for the UUID of a system as the chainload file. If it's not there, then it exits out. If it is there, it executes whatever is in the script.

Example embedded script:

Code:
#!ipxe
#Generic Boot Script

set 0_attempt 1

:0_retry

dhcp ||
isset ${17} && goto 0_next ||
iseq ${0_attempt} 3 && goto 0_end
iseq ${0_attempt} 2 && set 0_attempt 3
iseq ${0_attempt} 1 && set 0_attempt 2

goto 0_retry

:0_next

chain ${17}/ipxe/boot/${uuid}.ipxe ||

:0_end

exit



RE: starting script from command line - mrc333777 - 2012-12-06 19:01

hehe, thanks, can i have your already compiled ipxe.kpxe file that does this?

(2012-12-06 17:53)MultimediaMan Wrote:  Yes, or they embed them in the ipxe binary (undionly.kpxe/ipxe.pxe or ipxe.lkrn).

For the first time users, it would be safe to say that the CTRL-B command line is where you get your feet wet, but past that, it's all scripts on a webserver or a PHP engine.

That's the beauty of iPXE; you can compile a small embedded script which executes a certain repeatable process as specific or as general as you want; once that process is established, you can expand or leverage it further as you see fit.

Myself, I have an embedded script which attempt to dhcp (three times) and checks for the UUID of a system as the chainload file. If it's not there, then it exits out. If it is there, it executes whatever is in the script.

Example embedded script:

Code:
#!ipxe
#Generic Boot Script

set 0_attempt 1

:0_retry

dhcp ||
isset ${17} && goto 0_next ||
iseq ${0_attempt} 3 && goto 0_end
iseq ${0_attempt} 2 && set 0_attempt 3
iseq ${0_attempt} 1 && set 0_attempt 2

goto 0_retry

:0_next

chain ${17}/ipxe/boot/${uuid}.ipxe ||

:0_end

exit



RE: starting script from command line - MultimediaMan - 2012-12-07 00:48

You know, I almost attached it; but then I thought about this for a minute...

There are two things preventing me from doing this:

a) If I did that and it didn't work (for almost any reason), you would come to me for help instead of troubleshooting it.

b) Any updates you would also come to me for, and there have been well over 100 commits in the past year.

In other words:
Quote:If you build a fire for someone he is warm for a night. If you set him afire, he is warm for the rest of his life.
...No, that's not quite right.

Ahem...
Quote:If you build a fire for someone he is warm for a night. If you set him afire, he is warm for the rest of his life. If you teach him to build a fire, he is warm for the rest of his life.
...Better.

So if you want it, ~as is~, I will post it for 24 hours.


RE: starting script from command line - mrc333777 - 2012-12-07 00:59

yes, im just learning, anything to play with do i need linux to compile my own or can it be done in windows 8? i will take it as is

(2012-12-07 00:48)MultimediaMan Wrote:  You know, I almost attached it; but then I thought about this for a minute...

There are two things preventing me from doing this:

a) If I did that and it didn't work (for almost any reason), you would come to me for help instead of troubleshooting it.

b) Any updates you would also come to me for, and there have been well over 100 commits in the past year.

In other words:
Quote:If you build a fire for someone he is warm for a night. If you set him afire, he is warm for the rest of his life.
...No, that's not quite right.

Ahem...
Quote:If you build a fire for someone he is warm for a night. If you set him afire, he is warm for the rest of his life. If you teach him to build a fire, he is warm for the rest of his life.
...Better.

So if you want it, ~as is~, I will post it for 24 hours.



RE: starting script from command line - mrc333777 - 2012-12-07 06:37

this is pretty cool, learning alot from this, i just wanted to say that


RE: starting script from command line - robinsmidsrod - 2012-12-07 20:57

If you want more hands-on learning in a bit faster tempo, IRC is the place to be. Smile

The channel is called #ipxe, and we're on the server called irc.freenode.net. If you've never used IRC before, just google it and download an IRC client (or use a web client). Wikipedia is your friend. It also has some decent articles that explains how the PXE network boot system works.


RE: starting script from command line - mrc333777 - 2012-12-07 22:01

yea, i usually hang out on efnet, but sometimes freenode im there now as \\mr_c\\

(2012-12-07 20:57)robinsmidsrod Wrote:  If you want more hands-on learning in a bit faster tempo, IRC is the place to be. Smile

The channel is called #ipxe, and we're on the server called irc.freenode.net. If you've never used IRC before, just google it and download an IRC client (or use a web client). Wikipedia is your friend. It also has some decent articles that explains how the PXE network boot system works.



RE: starting script from command line - mrc333777 - 2012-12-09 18:34

really cool, i got it to work, my fire is lit now... hehe, back to your quote

(2012-12-06 19:01)mrc333777 Wrote:  hehe, thanks, can i have your already compiled ipxe.kpxe file that does this?

(2012-12-06 17:53)MultimediaMan Wrote:  Yes, or they embed them in the ipxe binary (undionly.kpxe/ipxe.pxe or ipxe.lkrn).

For the first time users, it would be safe to say that the CTRL-B command line is where you get your feet wet, but past that, it's all scripts on a webserver or a PHP engine.

That's the beauty of iPXE; you can compile a small embedded script which executes a certain repeatable process as specific or as general as you want; once that process is established, you can expand or leverage it further as you see fit.

Myself, I have an embedded script which attempt to dhcp (three times) and checks for the UUID of a system as the chainload file. If it's not there, then it exits out. If it is there, it executes whatever is in the script.

Example embedded script:

Code:
#!ipxe
#Generic Boot Script

set 0_attempt 1

:0_retry

dhcp ||
isset ${17} && goto 0_next ||
iseq ${0_attempt} 3 && goto 0_end
iseq ${0_attempt} 2 && set 0_attempt 3
iseq ${0_attempt} 1 && set 0_attempt 2

goto 0_retry

:0_next

chain ${17}/ipxe/boot/${uuid}.ipxe ||

:0_end

exit