Results 1 to 4 of 4

Thread: beginner scripting do scripts

  1. #1
    Join Date
    Jan 2012
    Beans
    3

    beginner scripting do scripts

    Ok, so when i used windows i liked incredibly much autohotkey www.autohotkey.com
    The coding was incredibly simple and powerful, i had a script in my startup that went something like this

    1 read settings.txt and store in variable %state%
    2 if %state% = 1
    2.1 msgbox timeout=10s "ABORTING /n run=cancel"
    2.2 if buttonpress=ok or buttonpress=timeout
    2.2.1 exitapp
    3 else
    3.1 msgbox timeout=10s "RUNNING /n run=wait,ok"
    3.2 if buttonpress=cancel
    3.2.1 exitapp
    4 loop all files in folder of script
    4.1 if filename<>scriptname and filename<>settings.txt
    4.1.1 run file
    5 exitapp
    (note code in ahk is not like the above, i just made something that is easy to understand by coders)

    if i have a project to make, i put all my shortcuts in the script folder, like notes, the app i use(or the project and when it runs it uses that app), editor for the project and stuff like that

    soo here are my worries, how do i create a script in ubuntu? i tried to make files that run in terminal or ask to be run in terminal and no matter what extension i gave them they just sit there and wait to be edited by the txt editor... i found in some of the ubuntu folders a file that asked to be run, basically when i want to create a script i just copy that file, delete everything inside it and copy in it what i want it to run (also change the name of the script)
    q1 how do i create a script that asks to be run in terminal?
    q2 can i create something like the above? with message boxes and other
    variables?

  2. #2
    Join Date
    Jan 2012
    Beans
    3

    Re: beginner scripting do scripts

    ohh yeah, i forgot in the script i also save the new state in the settings.txt XD
    soo if last time i started my computer i worked, now the script will start my working apps, and if last time i started my computer i did not work now it will not start my apps

  3. #3
    Join Date
    Oct 2009
    Location
    Reykjavík, Ísland
    Beans
    9,959
    Distro
    Lubuntu 14.10 Utopic Unicorn

    Re: beginner scripting do scripts

    Moved to Programming Talk.
    About problems due to upgrading
    Bringing old hardware back to life.
    Please visit Quick Links -> Unanswered Posts

  4. #4
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,010
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: beginner scripting do scripts

    Quote Originally Posted by pigmentty View Post
    Ok, so when i used windows i liked incredibly much autohotkey www.autohotkey.com
    The coding was incredibly simple and powerful, i had a script in my startup that went something like this

    1 read settings.txt and store in variable %state%
    2 if %state% = 1
    2.1 msgbox timeout=10s "ABORTING /n run=cancel"
    2.2 if buttonpress=ok or buttonpress=timeout
    2.2.1 exitapp
    3 else
    3.1 msgbox timeout=10s "RUNNING /n run=wait,ok"
    3.2 if buttonpress=cancel
    3.2.1 exitapp
    4 loop all files in folder of script
    4.1 if filename<>scriptname and filename<>settings.txt
    4.1.1 run file
    5 exitapp
    (note code in ahk is not like the above, i just made something that is easy to understand by coders)

    if i have a project to make, i put all my shortcuts in the script folder, like notes, the app i use(or the project and when it runs it uses that app), editor for the project and stuff like that

    soo here are my worries, how do i create a script in ubuntu? i tried to make files that run in terminal or ask to be run in terminal and no matter what extension i gave them they just sit there and wait to be edited by the txt editor... i found in some of the ubuntu folders a file that asked to be run, basically when i want to create a script i just copy that file, delete everything inside it and copy in it what i want it to run (also change the name of the script)
    q1 how do i create a script that asks to be run in terminal?
    q2 can i create something like the above? with message boxes and other
    variables?
    To run a script file in a terminal(or elsewhere) without explicitly specifying which interpreter to use to run it, you need to:

    1. Make the first line of the file contain: "#! /path/to/interpreter" (usually "#! /bin/sh", "#! /usr/bin/python" or "#! /bin/bash" and
    2. make the file executable by setting its "executable" flag: "chmod +x the_script_file"

    The rest of the instructions will now depend on the interpreter/language you choose.

Tags for this Thread

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
  •