Wednesday, August 10, 2011

Gambas FTP Server

Introductions:
Here we begin choosing which FTP server software is available and common, by browsing we stumbled to vsftpd, indeed it fits to our requirement. Gambas FTP client will use the vsftpd as its server and the Apache will be set-up so that we can access the data sent by the client to the FTP server via on-line.

At this time, we will need a browser hosted by apache2 and vsftpd for our FTP server , perhaps in the  second part ,its  browser will be embedded in the Gambas2 code. Or we will implement a peer to peer  FTP link between the client and the server all will be programmed in Gambas2.


Objectives:
1)To link our Gambas FTP client to Vsftpd server
2) The pulling of data is done through web browsing

Requirements:
Fedora 14 (32-63 bits)
Apache web server
Vsftpd server
libpam* or pam* libraries in Fedora


Methodology:
 
Let's install the basic requirements
root@localhost# yum install httpd
root@localhost# yum install vsftpd

Let's activate the service at start-up
root@localhost# chkconfig vsftpd on
root@localhost# yum install pam*

Let's create an account first and have its authentications
root@localhost# httpswd -c /etc/vsftpd/passwd/ cobe
root@localhost#

Or we can try also this one... * Create User to access Apache home
root@localhost# useradd -g apache -d /home/user user
root@localhost# passwd user

Set permissions to the apache2 web folder

root@localhost# vi /etc/group
apache:x:##:user

Create link to Apache home
root@localhost# ln -s /var/www/html /home/user/html

Set permissions in web root
root@localhost# chgrp -R apache *
root@localhost# chown -R apache *
root@localhost# chmod -R 775 *

Edit the vsftpd.conf

root@locahost# vim /etc/vsftpd.conf

Here are the configurations:
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/sites/$USER
chroot_local_user=YES
hide_ids=YES

Running or restarting the service of Vsftpd server
root@localhost# /etc/init.d/vsftpd start
root@localhost# /etc/init.d/vsftpd stop

Then let us check if the FTP server is really working...
root@localhost# ftp localhost
or
root@localhost# ftp 127.0.0.1

Now create the home folder of "cobe" as user and the correct setting of file access permissions .
root@localhost# mkdir /var/www/cobe
root@localhost# chmod +w /var/www/cobe

This time we can have a try again logging in the FTP server
root@localhost# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 Welcome to RoBook Scanner FTP service.
Name (127.0.0.1:robook): cobe
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

So let's now use our ftp client in gambas2 and upload files to vsftpd server.
Be sure to check the following:
1)Ownership of files in the folder
2)Correct IP address and its port
3) Username
4) Password
5) FTP port (if default or configured!)

Monday, July 18, 2011

Gambas FTP Client

Introductions:
Another interesting features of this programming language is the application in networking .More functions are added such as DNS,HTTP,UDP and I' ll have a try using the FTP clients.

The purpose of this simple tutorials is to include sending files to a remote server , in this case the choice is to do it with FTP clients- for a more faster and secure sending and getting files to a remote server.

Again , I am going to document it in this simple blog.



Requirements:
Gambas2
gb.net.curl

Functions:
Async
byteorder
close
EndofFile
EndofLine
gethandle
id
password
peek
proxy
put
status
stop
tag
timeout
url
user



Methodology:


Details(1) gb.net.curl FTP components in Gambas2


Details(2) Gambas2 project properties


Details(3):Icon for FTP service



Details(4)Properties of FTP components

 















Here is the source code

'-------------------------------------------------------------------------------------------------------
'SendFTPFile(spath AS String, sDataFileName AS String)
'Sending FTP File
'-------------------------------------------------------------------------------------------------------
PUBLIC SUB SendFTPFile(spath AS String, sFileName AS String, sDataFileName AS String) '(dataFile AS String) AS Boolean

DIM myFtp AS NEW FtpClient

'myFtp.URL = "ftp://10.36.129.163/disk1/RoBook/Test2.pdf"
myFtp.URL = spath & sFileName
myFtp.User = "Cobe"
 myFtp.Password = "***********"
'myFtp.Timeout = 120
myFtp.Put(sDataFileName)

END


'-------------------------------------------------------------------------------------------------------
'GetFTPFile(sPath AS String, sDataFileName AS String)
'Receiving FTP File  FTP File
'-------------------------------------------------------------------------------------------------------
PUBLIC SUB GetFTPFile(spath AS String, sDataFileName AS String)  '(dataFile AS String) AS Boolean

DIM myFtp AS NEW FtpClient

'myFtp.URL = "ftp://10.36.129.163/disk1/RoBook/ok.pdf"
myFtp.URL = spath & sDataFileName
myFtp.User = "Cobe"
myFtp.Password = "**********"
'myFtp.Timeout = 120
myFtp.Get("/home/robook/Desktop/ShortCourses145.pdf")

END


Remarks :

Conclusions:

Wednesday, July 6, 2011

Creating diretory in Gambas2 (Two)


Creating diretory in Gambas2

Introductions:
Hello here we are again, our next tutorials are the File & Directory functions available in Gambas2.It allows the flexibility of Gambas2 in manipulating files and its directories.Below are the list of the current features available in Gambas2 :

Requirements:

Access Tests the access authorization of a file.
COPY Copy a file.
DFree Returns the free space on a device.
Dir Browses a directory.
Exist Checks if a specific file or directory exists.
IsDir Returns if a path points at a directory.
KILL Removes a file.
LINK Creates a symbolic link.
MKDIR Creates a directory.
MOVE Renames or moves a file or a directory.
RDir Browses a directory recursively.
RMDIR Removes an empty directory.
Stat Get information about a file.
Temp$ Makes temporary file names.


Methodology:
1) Create a sample program
2) Choose 1 functions
3) Give examples
4) Discuss the output

Detail(1):Title project


Detail(2) : Create a form


Detail(3) A simple source code

Detail(4)


Detail(5) Run the program "File Directory"



Remarks:


Conclusions:

Monday, May 9, 2011

Serial Comm RS232 port Interface (Gambas2)


Introductions:

Serial communication is very important tools required in programming, its serial functions must be learned by a programmer too. In some electronic interfacing we frequently use serial interfacing RS232,RS485 and etc.

Requirements:
Gambas 2 interpreter/compiler
gb.net project component

Objectives:
1) To discuss the use of serial communications
2) To discuss the function of serial interface using gambas2
3) To demonstrate a simple program in gambas2


Methodology:
0) check the availability of serial port device " ls -l /dev/ttyS* "
1) check the ownership of "uccp" -default is owned by "root"
2) Open Gambas2
3) Add gb.net in the project component
3) Create a form
4) Specify setting in COM port:
Data bits
Flow control
Parity
Portname
Speed
Stopbits


Detail(1) Project properties to choose serial components


Detail(2) Icon for serial component


Detail(3) Serial Comm properties


Detail(4) Cut and paste source code
PRIVATE SComm AS SerialPort CONST None AS Integer = 0

PRIVATE Rx AS String  PUBLIC SUB Form_Open()
SComm = NEW SerialPort AS "SComm"
SComm.PortName = "/dev/ttyUSB0"
SComm.Speed = "19200"
SComm.Parity = 0
SComm.DataBits = "8"
SComm.StopBits = "1"
SComm.FlowControl = 0
TRY
SComm.Open()

IF ERROR THEN

TRY
SComm.PortName = "/dev/ttyS0"
SComm.Speed = "19200"
SComm.Parity = 0
SComm.DataBits = "8"
SComm.StopBits = "1"
SComm .FlowControl = 0

SComm.Open()

  IF ERROR THEN    
Message("No Serial Come Exiting...")
QUIT
ENDIF  

ENDIF

END  'Private RX

'******** Incoming serial data ********
PUBLIC SUB SComm _Read()
SLEEP 0.025
TRY READ #SComm , Rx, Lof(SComm )
IF ERROR THEN
Message.info(No received data!)
ENDIF

IF Len(Rx) > 8 THEN
TextBox1.Text= Cstr(Rx)
END IF

END

PUBLIC SUB Form_Close()
SComm.Close()
QUIT
END


Detail(5) Error message if serial port is not available


Detail(6): Checking serial port "ls -l /dev/ttyS*"


Detail(7) chown -R group.user /dev/ttyS0

Detail(8) Running serial interface -gambas2 example





Remarks:
Hints:
Problem: Can't open serial port#

1) Create a user and group to add it uucp(if you don't have a login-name)
root@localhost#groupmod –-add-user user_name uucp

2) change ownership (if you t have a login-name)
root@localhost# chown -R your_group.your_user /dev/ttyS0
Still on evaluations, and we hope that gambas2 developers
would add more features in the serial functions.

Problem: Can't have a faster read via serial port?
1) Try to empty first the buffer before reading the next data
buffer =""
buffer=read_serial()

2) of course you can adjust the faster baud rate your host device is capable too.


Conclusions:
A simple serial interfacing

E^3

Thursday, May 5, 2011

Installing Gambas3 in Fedora 14

Introductions:
There are more and more programmers are using gambas3 as their new VB6 like interpreter in Linux.It is so obvious that the widespread of its applications are being supported in the open community.

In this scratch article I will help you install Gambas3 and its easiest way, hoping 
that this tutorials could help you.
 
Good Luck 
 
 
Requirements:
Fedora OS
PC
Internet
 
Objectives:
1) To install Gambas3 in Fedora as easy as possible
2) To use Gambas3 in Linux programming applications 
 
Methodology:

Install the development tools and libraries 
root@localhost# yum groupinstall "Development Tools" "Development Libraries" 
 
Install the following apps: 
root@localhost# yum install  
cairo-devel libsqlite3x-devel 
sqlite2-devel 
gtk2-devel gtkglext-devel imlib2-devel librsvg2-devel 
poppler-devel qt-devel libv4l-devel 
SDL-devel SDL_sound-devel SDL_ttf-devel SDL_net-devel 
SDL_mixer-devel 
SDL_image-devel 
SDL_gfx-devel 
SDL_Pango-devel firebird-libfbclient unixODBC-devel 
postgresql-devel libXtst-devel 
mysql-devel pcre-devel mesa-libGLU-devel mesa-libGLw-devel 
mesa-libGL-devel glew-devel 
firebird-devel 
dbus-devel libzip libzip-devel 
bzip2-devel 
libcurl-devel qt-webkit-devel

Download Gambas3 from SVN 
root@localhost# mkdir gambas3-sources
root@localhost# cd gambas3-sources
root@localhost# svn checkout
 https://gambas.svn.sourceforge.net/svnroot/gambas/gambas/trunk/ 
 
Install  and configure Gambas3  
root@localhost# cd trunk 
root@localhost# ./reconf-all 
root@localhost# ./configure 
root@localhost# make 
root@localhost# make install  
 
 
Remarks:
Installing tools and libraries should be completed to avoid errors of compiling code in  Gambas3.To make sure you can download the files regardless of its number of versions, you may try doing this in yum: example: Sqlite
root@localhost@ yum install sqlite*

Conclusions:
This procedure of installations really help me for an instant installation of gambas3.This tutorial guides users the easy way of having gambas3 in their programming applications.
 
 
 

Tuesday, January 18, 2011

" Hello World " Gambas

Introductions:


Materials & References

Installations

Learning the basic

Running the code

A simple hello world

The next steps

Advance continuations

Howto Installations -Gambas





Building Gambas2
in Ubunto 10.9
root@localhost# sudo apt-get install build-essential autoconf libbz2-dev libfbclient2 libmysqlclient-dev unixodbc-dev libpq-dev \
libsqlite0-dev libsqlite3-dev libgtk2.0-dev libldap2-dev libcurl4-gnutls-dev libgtkglext1-dev libpcre3-dev \
libsdl-sound1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev libsage-dev libxml2-dev libxslt1-dev libbonobo2-dev \
libcos4-dev libomniorb4-dev librsvg2-dev libpoppler-dev libpoppler-glib-dev libasound2-dev libesd0-dev \
libdirectfb-dev libaa1-dev libxtst-dev libffi-dev kdelibs4-dev firebird2.1-dev libqt4-dev libglew1.5-dev \
libimlib2-dev libv4l-dev libsdl-ttf2.0-dev libgnome-keyring-dev libgdk-pixbuf2.0-dev mysql-client-core-5.1 mysql-server



Building Gambas2 in Fedora
root@localhost# sudo yum install gambas2-gb-db gambas2-gb-db-form \
gambas2-gb-db-mysql gambas2-gb-desktop \
gambas2-gb-form gambas2-gb-form-dialog \
gambas2-gb-form-mdi gambas2-gb-net \
gambas2-gb-net-curl gambas2-gb-net-smtp \
gambas2-gb-qt gambas2-gb-qt-ext \
gambas2-gb-settings gambas2-gb-xml \
gambas2-gb-xml-rpc gambas2-runtime

A timely Gambas

Introductions:


Everybody wanted an open source software

Breaking away with the digital divide


The need to learn

The cost

The academe

The developer


Our future R&D in opensource

Gambas rule..

Introductions to Gambas