VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: Programming in VectorLinux  (Read 1303 times)

killachains82

  • Member
  • *
  • Posts: 2
Programming in VectorLinux
« on: July 20, 2008, 05:28:18 am »

I'm a newbie to VL and want to learn to make executables and stuff. I've worked on XP for a while, so I do have some experience in programming. Here's a few questions:
1. Is there a language that the OS can execute directly from a file; For example: I can type some code into the file vlprogram and then execute it just like that
2. What file formats can VL execute i.e. exe's, dmg's, ...
Any help would be great

Thanks,
killachains82
Logged

kidd

  • Packager
  • Vectorian
  • ****
  • Posts: 682
Re: Programming in VectorLinux
« Reply #1 on: July 20, 2008, 05:56:08 am »

Hi killachains82 and welcome to VL

There is a subset of languages that can be executed (actually interpreted), so
no need to compile them.

Compiled languages are typicaly faster than interpreted ones, but depending on
your hardware and your needs you can do many things in interpreted languages.

Bash is the program that manages your console, so when you do 'cd
/home/killachains' in a terminal, the string is passed to bash, and it executes
that.

Although you can do logic statements and flow control statements in bash,
there are scripting languages that are more powerful than bash like perl or
pyhton.

if you have some programming background, you'll be able to code stuff in very
little time with those.

HTH

killachains82

  • Member
  • *
  • Posts: 2
Re: Programming in VectorLinux
« Reply #2 on: July 20, 2008, 06:18:37 am »

Hi kidd
Thanks for the help
I have another question: What is a shell script and is that written in bash?
Logged

wcs

  • Packager
  • Vectorian
  • ****
  • Posts: 1144
Re: Programming in VectorLinux
« Reply #3 on: July 20, 2008, 06:22:15 am »

Try typing some lines in a text file (as you would in a console). For example, the instruction to copy a file from one location to another.
At the top of the file put this:
Code: [Select]
#!/bin/bashThe file format will then be a bash script (regardless of the extension)... you might want to give it a .sh extension, but that's not needed.

To run it, type:
Code: [Select]
sh filename
Alternatively, you can right-click on the file, and in the properties, check "allow this file to run as a program" (assuming you're on xfce). Or (same thing), change its permissions to allow it to be executable like this:
Code: [Select]
chmod a+x filename
Then you can run it by just typing its name on a console, or by double-clicking on it in your file manager.

I suppose this is similar to a .bat file in Windows.

Besides the scripts (for bash and the other languages that kidd mentioned), VL can execute binary files that have been compiled for your architecture (whatever the language they were written on). They are not named .exe . They usually have no extension at all. The file icon will tell you if it's a binary file. For instance, go to /usr/bin and you'll find lots of executable files there (for your applications). To see the file format of a file in a console type:
Code: [Select]
file filenameThe file command we'll give you something like this:
Code: [Select]
file /usr/bin/xcalc
/usr/bin/xcalc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped

Hope this helps...
Logged

wcs

  • Packager
  • Vectorian
  • ****
  • Posts: 1144
Re: Programming in VectorLinux
« Reply #4 on: July 20, 2008, 06:24:57 am »

Quote
What is a shell script and is that written in bash?

What I said above would actually be a shell script.
You can however have scripts for different shells, bash being one of them, and the default one in VL.

Check http://en.wikipedia.org/wiki/Shell_(computing)
Logged