[U-Boot-Users] script examples...

Does anyone have an example of a script that does conditional work (i.e. if then else stuff)?
I want to have a script that checks for a file on an MMC card and do something if there and if not there do another.
Thanks, Michael Frey

Do you mean a shell script?
Like,
[ -f PATH ] && EXEC_THIS_COMMAND [ ! -f PATH ] && EXEC_ANOTHER_COMMAND
On Mon, Jun 23, 2003 at 03:18:54PM -0400, Michael Frey wrote:
Does anyone have an example of a script that does conditional work (i.e. if then else stuff)?
I want to have a script that checks for a file on an MMC card and do something if there and if not there do another.

In message 20030623193734.GB5179@buici.com you wrote:
Do you mean a shell script?
Like,
[ -f PATH ] && EXEC_THIS_COMMAND [ ! -f PATH ] && EXEC_ANOTHER_COMMAND
This doesn't work, as the current implementation of the hush shell does not contain a "test" command (and "[" is just an alias for "test").
You have to use the return status of existing commands, like
if fdosls <some_filename_here> then run command_1 else run command_2 fi
Best regards,
Wolfgang Denk

This sounds what I need but I get syntax errors when trying the following:
if fatls <filename> then run erase 0x00000000 0x0003ffff else run bootm fi
Should this work?
Michael
On Monday, June 23, 2003, at 03:57 PM, Wolfgang Denk wrote:
In message 20030623193734.GB5179@buici.com you wrote:
Do you mean a shell script?
Like,
[ -f PATH ] && EXEC_THIS_COMMAND [ ! -f PATH ] && EXEC_ANOTHER_COMMAND
This doesn't work, as the current implementation of the hush shell does not contain a "test" command (and "[" is just an alias for "test").
You have to use the return status of existing commands, like
if fdosls <some_filename_here> then run command_1 else run command_2 fi
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de Ninety-Ninety Rule of Project Schedules: The first ninety percent of the task takes ninety percent of the time, and the last ten percent takes the other ninety percent.
This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

In message 7C52E0B9-A5B7-11D7-A774-00039390D626@pepper.com you wrote:
This sounds what I need but I get syntax errors when trying the following:
Well, check with a real shell - the syntax is the same:
if fatls <filename> then run erase 0x00000000 0x0003ffff else run bootm fi
Should this work?
No, there is a separator missing. Either
if fatls <filename> then run erase 0x00000000 0x0003ffff else run bootm fi
or
if fatls <filename> ; then run erase 0x00000000 0x0003ffff else run bootm fi
should work.
One word of a warning, though: "run bootm" means you have defined a vaiable "bootm" which contains some commands; but there is also a U-Boot command "bootm" - there is no problem with that, it will actually work fine, but for matters of style I recommend to use different names, though.
Best regards,
Wolfgang Denk

ok thanks for the help.
I do intend to use the real built-in bootm command not my own.
Michael
On Monday, June 23, 2003, at 04:21 PM, Wolfgang Denk wrote:
In message 7C52E0B9-A5B7-11D7-A774-00039390D626@pepper.com you wrote:
This sounds what I need but I get syntax errors when trying the following:
Well, check with a real shell - the syntax is the same:
if fatls <filename> then run erase 0x00000000 0x0003ffff else run bootm fi
Should this work?
No, there is a separator missing. Either
if fatls <filename> then run erase 0x00000000 0x0003ffff else run bootm fi
or
if fatls <filename> ; then run erase 0x00000000 0x0003ffff else run bootm fi
should work.
One word of a warning, though: "run bootm" means you have defined a vaiable "bootm" which contains some commands; but there is also a U-Boot command "bootm" - there is no problem with that, it will actually work fine, but for matters of style I recommend to use different names, though.
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de If I had to live my life again, I'd make the same mistakes, only sooner. -- Tallulah Bankhead
participants (3)
-
Marc Singer
-
Michael Frey
-
Wolfgang Denk