WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED]Running a script in Terminal  (Read 18682 times)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: [SOLVED]Running a script in Terminal
« Reply #15 on: March 07, 2013, 02:16:02 PM »
Virtual Box has nothing to do with the 3G modem.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: [SOLVED]Running a script in Terminal
« Reply #16 on: March 07, 2013, 02:20:08 PM »
Could well be but TC definitely did not see an internet connection.
Not really a problem as I have ordered a router with 3G on it and 4 ethernet ports
so I will be able to give the TC box a straight ethernet connection when I get my router
in a couple of days.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Running a script in Terminal
« Reply #17 on: March 07, 2013, 06:52:02 PM »
Perl was installed but I used the wrong shebang in the perl script, it was #!/bin/perl and
when I changed it to #!/usr/bin/perl all is well.
Declaring a perl script as
Code: [Select]
#!/usr/bin/env perlcould prevent such issues ;)
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Running a script in Terminal
« Reply #18 on: March 07, 2013, 07:04:05 PM »
I would prefer to have bash as all of my scripts are for bash and I understand there are some
differences between bash and ash.

This has nothing to do with preferences at all.
When bash encounters a script declared as
Code: [Select]
#!/bin/shit will automatically run in posix mode.

If a script which is posix compatible is declared as
Code: [Select]
#!/bin/bashthen that's a bug, while using bashisms where not required for functionality is simply bad coding ;)

"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Running a script in Terminal
« Reply #19 on: March 07, 2013, 07:18:09 PM »
OK, understood but keep in mind that I don't have an internet connection on my TC box, so I'm using
my Win box to download the required files and then put them on the same usb drive as TC.

The only repo I could find is ftp://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/tcz.html
There are all the .tcz .info .list .md5 and in some cases a .dep (there are no .tree files).
However there is no .dep for bash.tcz

There is a script for downloading extensions without appbrowser access here:

http://forum.tinycorelinux.net/index.php/topic,7243.0.html

not sure to which extent it is still functional as of current.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: [SOLVED]Running a script in Terminal
« Reply #20 on: March 08, 2013, 12:26:46 PM »
Hi tinypoodle

Perhaps I'm misunderstanding you, but I thought that Bash and Ash were two different shells and interpreters
and Linux calls the selected interpreter depending on the shebang.

I can't see how putting bash in the shebang is considered bad programming considering how often it's used in the Linux environment.
« Last Edit: March 08, 2013, 12:32:29 PM by Paulo »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: [SOLVED]Running a script in Terminal
« Reply #21 on: March 08, 2013, 12:43:42 PM »
Different  distros have different default shells.  The default shell is usually linked to /bin/sh.
Please re-read reply #18.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: [SOLVED]Running a script in Terminal
« Reply #22 on: March 08, 2013, 12:57:02 PM »
I understand that different distros use different default shells, just that I need to use Bash
because that is what is needed for BaCon (www.basic-converter.org).

I have since loaded Bash and all is well.



Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: [SOLVED]Running a script in Terminal
« Reply #23 on: March 08, 2013, 03:04:01 PM »
I understand that different distros use different default shells, just that I need to use Bash
because that is what is needed for BaCon (www.basic-converter.org).

I have since loaded Bash and all is well.

OMG

It doesn't need bash. It is written in bash. A BASIC to C converter.

OMG
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: [SOLVED]Running a script in Terminal
« Reply #24 on: March 08, 2013, 03:33:14 PM »
It needs BASH3.2 or later (+ gcc)
The convertor script will obviously not work without Bash as is the case with TC.

From the Bacon website:
Quote
BaCon Bash version (requires BASH 3.2 or higher)

There are other versions available that are in compiled form but the reason why I use the
Bash version is two fold:

1) I know Bash

2) The source is easy to change when needed.

As an example, I needed to use the BaCon command "USEC" (to embed C code into my Basic pgm) and one of the header files
I needed to use was io.h and BaCon was not creating the resulting C source code (and hence the final executable could not be compiled)
that included io.h, no problem I modified the BaCon Bash source and problem solved.

By the way, BaCon is more then a Basic to C convertor as it will create the elf executable as well by calling gcc and passing it the created C file.
It can also compile shared libs from Basic programs.
« Last Edit: March 08, 2013, 03:53:34 PM by Paulo »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: [SOLVED]Running a script in Terminal
« Reply #25 on: March 08, 2013, 11:09:55 PM »
Hi tinypoodle

Perhaps I'm misunderstanding you, but I thought that Bash and Ash were two different shells and interpreters
and Linux calls the selected interpreter depending on the shebang.
Yes but...
- "#!/bin/sh" MUST be posix compliant on ANY UNIX-like system, which insures portability.
- If "#!/bin/sh" is a link to bash, then bash will automatically run in posix mode when encountering a script declared as "#!/bin/sh".
- ash - amongst other - is natively posix compliant, as opposed to bash.
- scripts declared as "#!/bin/bash" will ONLY run on systems where bash is installed AND linked to "#!/bin/bash"

Quote
I can't see how putting bash in the shebang is considered bad programming considering how often it's used in the Linux environment.

That is a total misrepresentation of what I said.

Let me try to put it differently:
1. posix compatible script declared as "#!/bin/bash" = bug
2. using bashisms where not required for functionality - and therefore creating a NEED for a "#!/bin/bash" declaration = bad coding
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: [SOLVED]Running a script in Terminal
« Reply #26 on: March 09, 2013, 02:27:56 AM »
I understand that one can make a link to run Bash if #!/bin/sh is called however Bacon still needs Bash
or are you saying that if I change the shebang of Bacon.bash script (www.basic-converter.org/stable/bacon.bash)
it will run with no problems?

My intention is not to be argumentative however I can't see ash and bash being 100% compatible else the author
of BaCon would have mentioned something to that effect.

I know that Bash has attracted a lot of criticism but I have never had a problem on any distro by using #!/bin/bash
once Bash is installed.
Since I use BaCon a lot, I'm happy to overlook the fact that #!/bin/bash may not be 100% correct but it gets the job done.
I use Mint, Puppy, SysrescCD (Gentoo) and now TC and can write and compile apps in Basic on all of them now and by keeping
everything the same it makes my life a lot easier.
« Last Edit: March 09, 2013, 02:40:35 AM by Paulo »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: [SOLVED]Running a script in Terminal
« Reply #27 on: March 09, 2013, 02:38:24 AM »
If you want to run scripts which explicitly depend on bash, then you have to install bash - and possibly link bash to /bin/bash on systems where that is not automatically done (it is with core).
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: [SOLVED]Running a script in Terminal
« Reply #28 on: March 09, 2013, 02:46:39 AM »
I did install Bash on TC (see reply #12) , checked that #!/bin/bash does point to Bash and problem solved.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: [SOLVED]Running a script in Terminal
« Reply #29 on: March 09, 2013, 03:35:41 AM »
I know that Bash has attracted a lot of criticism but I have never had a problem on any distro by using #!/bin/bash
once Bash is installed.
I have witnessed users of a FreeBSD system being perplex how they could execute bash manually but their scripts declared as "#!/bin/bash" would not run.
Reason being that the administrator wouldn't link /usr/local/bin/bash to /bin/bash.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)