Find the answer to your Linux question:
Results 1 to 7 of 7
well im totally new in linux (today started), i was trying create a new folder from a Lua console with the function os.execute() i ve done it in window without ...
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Posts
    3

    mkdir from Lua

    well im totally new in linux (today started), i was trying create a new folder from a Lua console with the function os.execute() i ve done it in window without problems, i already tried many ways, also executing the same commands from PuTTY works fine.

    from lua tries

    os.execute("mkdir testfolder")
    os.execute("cd /home/myname ; mkdir testfolder")
    os.execute("mkdir home/myname/testfolder")

    none works but using PuTTY they works fine =/

    of course the lua console is running in the linux host.

    please any help

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    In linux C programming , mkdir() function will create a directory.
    something like
    mkdir"/path/to/dir",077);
    I don't know about Lua. Can you invoke mkdir() from Lua? check that
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Feb 2010
    Posts
    3
    Quote Originally Posted by Lakshmipathi View Post
    In linux C programming , mkdir() function will create a directory.
    something like


    I don't know about Lua. Can you invoke mkdir() from Lua? check that

    you can invoke any os command using os.execute() its just like have a cmd console

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    I don't have experience on Lua, a quick google gave me this ,
    os.execute and bash environment variables - scite-interest | Google Groups

    HTH
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  5. #5
    Just Joined!
    Join Date
    Feb 2010
    Posts
    3
    Quote Originally Posted by Lakshmipathi View Post
    I don't have experience on Lua, a quick google gave me this <i cannot post urls>

    HTH

    thank you

  6. #6
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Exclamation

    ...<i cannot post urls>
    ha ha looks like you are strictly following forums rules
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  7. #7
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,116
    Hi.

    I am not a good enough typist to use the interactive mode, so from a script:
    Code:
    #!/usr/bin/env lua
    
    -- @(#) l1	Demonstrate feature.
    
    print("Hello World")
    os.execute("ls")
    dirname = "scratch"
    os.execute("mkdir " .. dirname)
    os.execute("ls")
    this produces:
    Code:
    % ./s1
    Hello World
    s1
    s1  scratch
    That small snippet -- mkdir -- also worked interactively.

    Copied from Programming in Lua : 22.2 ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

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