Recommendation for simple programming language for utilities
- veronicathecow
- Posts: 559
- Joined: Sat 21 Oct 2006, 09:41
Recommendation for simple programming language for utilities
Hi, I want to try and muck around making a few little utilities to do things like mount drives.
Can anyone recommend a simple language for me to use (I've used Spectrum Basic, QBasic, Visual Basic and many years ago some hex 8085)
Something to make some simple boxes and to be able to use command like Mount.
Any thoughts appreciated but please remember I really am a beginner here and work best by seeing example programs that are commented.
Many thanks
Can anyone recommend a simple language for me to use (I've used Spectrum Basic, QBasic, Visual Basic and many years ago some hex 8085)
Something to make some simple boxes and to be able to use command like Mount.
Any thoughts appreciated but please remember I really am a beginner here and work best by seeing example programs that are commented.
Many thanks
- Lobster
- Official Crustacean
- Posts: 15522
- Joined: Wed 04 May 2005, 06:06
- Location: Paradox Realm
- Contact:
There are many reasons why I suggest using BASH
Dialects of Basic (such as Puppy Basic) still await a comprehensive manual / tutorial
Bash is VERY powerful, the chances are you will be calling BASH (Bourne Again SHell) from your choosen language
http://puppylinux.org/wikka/ProgrammingLanguage
http://puppylinux.org/wikka/PuppyBasic
You can make simple boxes and things with bash using dialog or one of its variants. Not that pretty but it works.
If you know and love any perl: perlgtk or perlgtk2 is quite a powerful gui methodology, I've used it. A good example of a well-known program with a perlgtk GUI would be dvd::rip. It's not trivial to learn, and you need to know a little perl.
Lua guis using flua (is it?) and John Murga's own MurgaLua is a very light and fast GUI language, used with great effect in damnsmalllinux. Lua addicts swear by it..
BTW, the two most useful languages you can learn in linux are bash and perl. The former glues most systems together and is the lingua franca; the latter can just about do anything.
If you know and love any perl: perlgtk or perlgtk2 is quite a powerful gui methodology, I've used it. A good example of a well-known program with a perlgtk GUI would be dvd::rip. It's not trivial to learn, and you need to know a little perl.
Lua guis using flua (is it?) and John Murga's own MurgaLua is a very light and fast GUI language, used with great effect in damnsmalllinux. Lua addicts swear by it..
BTW, the two most useful languages you can learn in linux are bash and perl. The former glues most systems together and is the lingua franca; the latter can just about do anything.
Simple programming languages
Dear VtC,
If you really don't like bash's crypting syntax, you can use a variety of interpreters out there as shells. FreeBasic comes with fbsh - which is a scripting Basic you can use to write your own "bash-like" scripts in Basic. You could also get brandy (BB Basic V, as in Acorn and Archimedes), WSbasic or MoleBasic. They are rather small. WS weighs in at 119k and BBC basic (brandy) is not much larger (at 194k). You need to include the "shebang" character combination at the top of your basic script to get it to run "automatically". All the above allow you to execute external (i.e. Unix) commands and to get the results back from either stderr or stdout. What follows is just a silly WSbasic example I did for demonstration purposes. What is key here is that I get the ls listing (or any output) into a variable and can then manipulate it or use it, for instance, to control conditional branching. If you're interested I could upload my recently compiled verions brandy and wsbasic for you to have a look at.
With kind regards,
vovchik
-------------------
#!/usr/local/bin/wsbasic
# usage: p <target address for ping> (the default is my ISP gateway)
# -------------------------------------------------------------------
# This script pings a target address five times every 60 seconds and
# then shows the results in a terminal. The program continues in
# an endless loop until Ctrl-C is pressed. All functions must be defined
# at the top, before the actual program is invoked. The default target
# address can be changed via the default_addr var in the initialize
# variables section (set to my local IP by default).
# 29 April 2007, vovchik
# -------------------------------------------------------------------
# define printx - print external function
# -------------------------------------------------------------------
# this function removes the last byte from stringvars
# passed to wsbasic via an external call - i.e. run(x) - that terminate with a
# a superfluous LF.
function printx(xstring)
begin
print left(xstring,len(xstring)-1)
end # end function printx()
# -------------------------------------------------------------------
# define makeline - string concatenation function
# -------------------------------------------------------------------
# this function creates a long string of hyphens, used to separate
# elements of the screen display.
function makeline(stringvar,integer)
begin
catstring = ""
for xx = 1 to integer
begin
catstring = catstring + stringvar
end
return catstring
end # end function makeline()
# -------------------------------------------------------------------
# initialize variables - some only for the sake of Pascal-like formality
# -------------------------------------------------------------------
cmd_line = "" # only a formalism
xstring = "" # only a formalism
target_addr = "" # only a formalism
default_addr = "192.168.0.1" # default ping target - change to suit your needs
null_string = "" # just initialization of string
dummy_var = 0 # dummy var value for endless loop
run_count = 0 # iteration counter - only for information
hyphen = "-" # char passed to makeline function
long_line = makeline(hyphen,70) # invocation of function to create long hyphen string
ping_cmd="ping -c 5 " # actual unix ping command for 5 ping requests
delay = 60 # duration of delay (seconds) between invocations
getdate="date" # unix date command
usr_msg = "Pausing for " + delay + " seconds... Interrupt program with Ctrl-C."
# -------------------------------------------------------------------
# check the command line for arguments
# -------------------------------------------------------------------
# Wsbasic, when run as a shell interpreter, assigns #$ to the complete
# command line. This includes arg $0 as /usr/local/bin/wsbasic (in
# my case) and arg $1 as the actual program being run (p in this case).
# The first real arg - i.e., the first parameter passed to the program - is $2.
cmd_line = $2
if cmd_line==""
begin
target_addr = default_addr
end
else
begin
target_addr = $2
end # end of cmd_line argument check
# -------------------------------------------------------------------
# start main program - endless loop
# -------------------------------------------------------------------
while dummy_var < 1
begin
print long_line
run_count = run_count + 1
print "Iteration: ", run_count
a=run(getdate)
printx(a)
print long_line
do_ping=run(ping_cmd + target_addr)
printx(do_ping)
print long_line
print usr_msg
do_delay=run("sleep " + delay)
print null_string
end # end of main endless while loop
If you really don't like bash's crypting syntax, you can use a variety of interpreters out there as shells. FreeBasic comes with fbsh - which is a scripting Basic you can use to write your own "bash-like" scripts in Basic. You could also get brandy (BB Basic V, as in Acorn and Archimedes), WSbasic or MoleBasic. They are rather small. WS weighs in at 119k and BBC basic (brandy) is not much larger (at 194k). You need to include the "shebang" character combination at the top of your basic script to get it to run "automatically". All the above allow you to execute external (i.e. Unix) commands and to get the results back from either stderr or stdout. What follows is just a silly WSbasic example I did for demonstration purposes. What is key here is that I get the ls listing (or any output) into a variable and can then manipulate it or use it, for instance, to control conditional branching. If you're interested I could upload my recently compiled verions brandy and wsbasic for you to have a look at.
With kind regards,
vovchik
-------------------
#!/usr/local/bin/wsbasic
# usage: p <target address for ping> (the default is my ISP gateway)
# -------------------------------------------------------------------
# This script pings a target address five times every 60 seconds and
# then shows the results in a terminal. The program continues in
# an endless loop until Ctrl-C is pressed. All functions must be defined
# at the top, before the actual program is invoked. The default target
# address can be changed via the default_addr var in the initialize
# variables section (set to my local IP by default).
# 29 April 2007, vovchik
# -------------------------------------------------------------------
# define printx - print external function
# -------------------------------------------------------------------
# this function removes the last byte from stringvars
# passed to wsbasic via an external call - i.e. run(x) - that terminate with a
# a superfluous LF.
function printx(xstring)
begin
print left(xstring,len(xstring)-1)
end # end function printx()
# -------------------------------------------------------------------
# define makeline - string concatenation function
# -------------------------------------------------------------------
# this function creates a long string of hyphens, used to separate
# elements of the screen display.
function makeline(stringvar,integer)
begin
catstring = ""
for xx = 1 to integer
begin
catstring = catstring + stringvar
end
return catstring
end # end function makeline()
# -------------------------------------------------------------------
# initialize variables - some only for the sake of Pascal-like formality
# -------------------------------------------------------------------
cmd_line = "" # only a formalism
xstring = "" # only a formalism
target_addr = "" # only a formalism
default_addr = "192.168.0.1" # default ping target - change to suit your needs
null_string = "" # just initialization of string
dummy_var = 0 # dummy var value for endless loop
run_count = 0 # iteration counter - only for information
hyphen = "-" # char passed to makeline function
long_line = makeline(hyphen,70) # invocation of function to create long hyphen string
ping_cmd="ping -c 5 " # actual unix ping command for 5 ping requests
delay = 60 # duration of delay (seconds) between invocations
getdate="date" # unix date command
usr_msg = "Pausing for " + delay + " seconds... Interrupt program with Ctrl-C."
# -------------------------------------------------------------------
# check the command line for arguments
# -------------------------------------------------------------------
# Wsbasic, when run as a shell interpreter, assigns #$ to the complete
# command line. This includes arg $0 as /usr/local/bin/wsbasic (in
# my case) and arg $1 as the actual program being run (p in this case).
# The first real arg - i.e., the first parameter passed to the program - is $2.
cmd_line = $2
if cmd_line==""
begin
target_addr = default_addr
end
else
begin
target_addr = $2
end # end of cmd_line argument check
# -------------------------------------------------------------------
# start main program - endless loop
# -------------------------------------------------------------------
while dummy_var < 1
begin
print long_line
run_count = run_count + 1
print "Iteration: ", run_count
a=run(getdate)
printx(a)
print long_line
do_ping=run(ping_cmd + target_addr)
printx(do_ping)
print long_line
print usr_msg
do_delay=run("sleep " + delay)
print null_string
end # end of main endless while loop
I recommend Ruby. http://www.ruby-lang.org Theres an online tutorial on the side.
vovchick,
If I could get hold of a version of BBC Basic (aka brandy) that worked in Puppy I would never ask for anything else on this forum ever again! (Until I think of something else.)
How could I get a copy and what would I have to do to get it working in Puppy?
25 years ago many people in the UK (including lots of school-children) cut their programming teeth on BBC Basic. I'm sure all of the more modern languages have many fine features, but a structured basic on linux sounds perfect.
drongo
If I could get hold of a version of BBC Basic (aka brandy) that worked in Puppy I would never ask for anything else on this forum ever again! (Until I think of something else.)
How could I get a copy and what would I have to do to get it working in Puppy?
25 years ago many people in the UK (including lots of school-children) cut their programming teeth on BBC Basic. I'm sure all of the more modern languages have many fine features, but a structured basic on linux sounds perfect.
drongo
Brandy here
Dear Drongo - and VtC,
Here is a little archive containing the brandy interpreter, documentation and some examples. Please unpack the archive to /tmp and then copy the contents to appropriate directories. Brandy (located in the archive within /usr/local/bin) should be copied into your /usr/local/bin. The documentation and examples (some also by me - and rather crude but very structured) should go into /root/my-applications/bin/brandy (or wherever you wish). Let me know whether brandy runs on your system. I compiled it under Puppy 2.10 and all dependecies were satisfied in my setup. When running as a shell, brandy needs the -quit parameter on the unix shebang line. Look at my program d1 in the examples and you'll understand.
With kind regards,
Vovchik
Here is a little archive containing the brandy interpreter, documentation and some examples. Please unpack the archive to /tmp and then copy the contents to appropriate directories. Brandy (located in the archive within /usr/local/bin) should be copied into your /usr/local/bin. The documentation and examples (some also by me - and rather crude but very structured) should go into /root/my-applications/bin/brandy (or wherever you wish). Let me know whether brandy runs on your system. I compiled it under Puppy 2.10 and all dependecies were satisfied in my setup. When running as a shell, brandy needs the -quit parameter on the unix shebang line. Look at my program d1 in the examples and you'll understand.
With kind regards,
Vovchik
Examples
Dear drongo,
I never got around to finishing the brandygtk and xec1 examples, since I was only playing with brandy and had about one hour of experience with the language at the time of writing them. At some point I will actually finish them - particularly ones that launch gtk menu-builders - and will then post them. As to your question, to run my examples, simply type:
./progname
when in a terminal.
I agree with Lobster that brandy is a nice language, and it satisfies my requirement for structure and strong variable typing - fewer mistakes that way and the coding is much more transparent than would be otherwise. As you might be able to tell from my little examples, I come from the ancient "Pascal school".
By the way, has anybody seen a reasonable Pascal interpreter? As far as compilers go, there is FreePascal, GNU Pascal, Kylix and something beginning with the letter "N", but I am looking for a small interpreter something like brandy (although, perhaps, brandy will suffice, since I can rewrite most of the statements as procedures with pascal-like names and throw them all into an external lib).
With kind regards,
vovchik
I never got around to finishing the brandygtk and xec1 examples, since I was only playing with brandy and had about one hour of experience with the language at the time of writing them. At some point I will actually finish them - particularly ones that launch gtk menu-builders - and will then post them. As to your question, to run my examples, simply type:
./progname
when in a terminal.
I agree with Lobster that brandy is a nice language, and it satisfies my requirement for structure and strong variable typing - fewer mistakes that way and the coding is much more transparent than would be otherwise. As you might be able to tell from my little examples, I come from the ancient "Pascal school".
By the way, has anybody seen a reasonable Pascal interpreter? As far as compilers go, there is FreePascal, GNU Pascal, Kylix and something beginning with the letter "N", but I am looking for a small interpreter something like brandy (although, perhaps, brandy will suffice, since I can rewrite most of the statements as procedures with pascal-like names and throw them all into an external lib).
With kind regards,
vovchik
veronicathecow must be rather confused by now, all the choices & no clarity.
For the simple GUIs that I made for LanPuppy I used Bash & GTKdialog.
It's crude but simple... Just what you've asked for.
The most complex is a TabPanel of 5 tabs for: AddUsers, AddHosts, Options, etc.
I've also made a file mounter, partition boot mounter, & Samba share mounter.
If your interested, ask & I'll PM you several GUIs & some text help.
For the simple GUIs that I made for LanPuppy I used Bash & GTKdialog.
It's crude but simple... Just what you've asked for.
The most complex is a TabPanel of 5 tabs for: AddUsers, AddHosts, Options, etc.
I've also made a file mounter, partition boot mounter, & Samba share mounter.
If your interested, ask & I'll PM you several GUIs & some text help.
- veronicathecow
- Posts: 559
- Joined: Sat 21 Oct 2006, 09:41
Hi Everyone, my apologies for not being around for a while but a combination of computer problems and lack of cash means that I am having to spend my time doing my book business and sorting out my VERY late Tax. Many thanks for your information and I hope to be back helping in what way I can in a few weeks and I'm sorry for letting you down.
All the best
Tony
All the best
Tony