Results 1 to 10 of 10

Thread: is that possible ubuntu install services like window?

  1. #1
    Join Date
    Jan 2013
    Beans
    17

    is that possible ubuntu install services like window?

    i have develop a services can run properly in window server 2008,
    it is develop by Delphi or VB.NET
    is those services can install in Ubuntu Server GUI Mode?
    and how to install?
    or
    i can use any language to develop a service? like the window service one.
    but make sure can be install and run properly in ubuntu/Linux
    Last edited by chinye2020; January 4th, 2013 at 06:40 PM.

  2. #2
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu 17.04 Zesty Zapus

    Re: is that possible ubuntu install services like window?

    Moved to Server Platforms.

  3. #3
    Join Date
    Jan 2013
    Beans
    17

    develop a service like Window service

    i want to develop a service like window service in Ubuntu,
    this service is a server listener, will listening port 6903,
    and waiting any packets receive and save to the MySQl database.
    i would like to know which language can be develop and work properly in Ubuntu?
    is that Vb.NET or Delphi possible?

  4. #4
    Join Date
    Dec 2008
    Location
    Roorkee
    Beans
    11
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: develop a service like Window service

    Well it is possible. Well for ubuntu you can go for wide range of options but I will propose you go for python (quite easy to implement) or C/C++. .NET framework is not inherently supported on linux except you can try mono. But if you want something solid on linux/ubuntu go for python or C/C++. Then create a library and run it as service using inbuilt features of linux.

  5. #5
    Join Date
    Apr 2007
    Beans
    616
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: develop a service like Window service

    Quote Originally Posted by chinye2020 View Post
    i want to develop a service like window service in Ubuntu,
    this service is a server listener, will listening port 6903,
    and waiting any packets receive and save to the MySQl database.
    i would like to know which language can be develop and work properly in Ubuntu?
    is that Vb.NET or Delphi possible?
    in my opinion "services" are actually easier to write on Linux then they are in windows, nothing really special needed. As far as which language, pick your favorite. You mention VB.Net, which is a Microsoft product who does not support Linux, however if you can code in c# then you can use mono, Delphi is a flavor of Pascal which you can use Lazarus with free Pascal if that is your preference. Mine is Python, but they all work.

    Code what you want, and just start it as a daemon, in Linux daemons (services) do not need to be started or managed in any special way. Howeve if you really want to manage it the correct way (startup when your computer starts ect) you will have to write an upstart script (http://upstart.ubuntu.com/)

  6. #6
    Join Date
    Sep 2010
    Location
    Sweden
    Beans
    Hidden!

    Re: develop a service like Window service

    I think Python would be a good choice. Here's a rough draft I made - I don't know if it works as I haven't tested it, but see it as an overview.

    Code:
    import socket
    import _mysql
    import sys
    
    try:
        username = sys.argv[1]
        password = sys.argv[2]
        port = sys.argv[3]
        db_name = sys.argv[4]
        table_name = sys.argv[5]
        host = ''
    
    except IndexError:
        print "Error: "
        print "Be sure to specify username, password, port, database name and table name.\n"
        print "Syntax: ./script.py username password port db_name table_name."
        print "Example: ./script.py hank mypass 8762 testdb test_table"
        print "\nExit..."
        sys.exit(1)
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((host, port))
    s.listen(1)
    
    c, addr = s.accept()
    
    while 1:
        data = c.recv(1024)
        if not data: break
    c.close()
    
    mysql_c = None
    
    try:
        mysql_c = _mysql.connect('localhost', username, password, db_name)
        mysql_c.query('insert into '+table_name+' values '+data)
    
    except _mysql.Error, e:
        print "Error: %d: %s " % (e.args[0], e.args[1])
        sys.exit(1)
    
    finally:
        if mysql_c:
            mysql_c.close()
    Relevant links:

    http://docs.python.org/2/library/socket.html
    http://mysql-python.sourceforge.net/MySQLdb.html

  7. #7
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,025
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: is that possible ubuntu install services like window?

    Quote Originally Posted by oldos2er View Post
    Moved to Server Platforms.
    it's a programming question, really.

  8. #8
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,025
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: is that possible ubuntu install services like window?

    Quote Originally Posted by chinye2020 View Post
    i have develop a services can run properly in window server 2008,
    it is develop by Delphi or VB.NET
    is those services can install in Ubuntu Server GUI Mode?
    and how to install?
    or
    i can use any language to develop a service? like the window service one.
    but make sure can be install and run properly in ubuntu/Linux
    It's not really a quastion of what language, but of compilers. You need to compile your "service" so that it will run on Linux.
    Also, if you've written it in a way that relies on windows system stuff (components, libraries, ...), it will obviously only work on Windows.

  9. #9
    Join Date
    Mar 2006
    Location
    Williams Lake
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: is that possible ubuntu install services like window?

    Quote Originally Posted by chinye2020 View Post
    i have develop a services can run properly in window server 2008,
    it is develop by Delphi or VB.NET
    is those services can install in Ubuntu Server GUI Mode?
    and how to install?
    or
    i can use any language to develop a service? like the window service one.
    but make sure can be install and run properly in ubuntu/Linux
    What type of service are you wanting to set up, as it may already be available in the repositories. BTW, the server does not come with a gui of any sort, so if you feel you need one, you will have to install it yourself.

    Note: I've merged your two threads, as one of the other staff moved the thread from where it was to this sub-forum.
    Last edited by cariboo; January 5th, 2013 at 01:19 AM.

  10. #10
    Join Date
    Jan 2013
    Beans
    17

    Re: develop a service like Window service

    Quote Originally Posted by gnush View Post
    I think Python would be a good choice. Here's a rough draft I made - I don't know if it works as I haven't tested it, but see it as an overview.

    Code:
    import socket
    import _mysql
    import sys
    
    try:
        username = sys.argv[1]
        password = sys.argv[2]
        port = sys.argv[3]
        db_name = sys.argv[4]
        table_name = sys.argv[5]
        host = ''
    
    except IndexError:
        print "Error: "
        print "Be sure to specify username, password, port, database name and table name.\n"
        print "Syntax: ./script.py username password port db_name table_name."
        print "Example: ./script.py hank mypass 8762 testdb test_table"
        print "\nExit..."
        sys.exit(1)
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((host, port))
    s.listen(1)
    
    c, addr = s.accept()
    
    while 1:
        data = c.recv(1024)
        if not data: break
    c.close()
    
    mysql_c = None
    
    try:
        mysql_c = _mysql.connect('localhost', username, password, db_name)
        mysql_c.query('insert into '+table_name+' values '+data)
    
    except _mysql.Error, e:
        print "Error: %d: %s " % (e.args[0], e.args[1])
        sys.exit(1)
    
    finally:
        if mysql_c:
            mysql_c.close()
    Relevant links:

    http://docs.python.org/2/library/socket.html
    http://mysql-python.sourceforge.net/MySQLdb.html
    Wow!? Python code seen like quite easy...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •