LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   scripting (http://www.linuxquestions.org/questions/linux-newbie-8/scripting-761462/)

linux@cpu-computers.com 10-12-2009 04:52 PM

scripting
 
How do i create a basic script file. I want to be able to click on an icon on the desktop and be able to run a few linux commands from within the prompt.. Kinda like a BATCH file..

Any ideas? I'm sure its easy... when you know how.

weibullguy 10-12-2009 04:55 PM

You create it in your favorite text editor, like Vim. See here --> http://tldp.org/LDP/abs/html/abs-guide.html. Don't worry that it says "Advanced."

chrism01 10-12-2009 05:43 PM

Here's another good tutorial: http://rute.2038bug.com/index.html.gz

catkin 10-13-2009 01:32 AM

Quote:

Originally Posted by linux@cpu-computers.com (Post 3716961)
How do i create a basic script file. I want to be able to click on an icon on the desktop and be able to run a few linux commands from within the prompt.. Kinda like a BATCH file..

Any ideas? I'm sure its easy... when you know how.

There are two parts to the answer. The first is about writing the script which you can test from the command line.

Once that's working the second part is how to create an icon on the desktop that will open a terminal, run the script and leave the terminal open (assuming you want to see the ouput from the script). This second part is harder and the specifics depend on which Desktop, which Terminal Emulator and which scripting language you are using. Which are you using? There are many scripting languages; the "obvious" choice is bash.

linux@cpu-computers.com 10-15-2009 05:53 PM

Quote:

Originally Posted by catkin (Post 3717310)
There are two parts to the answer. The first is about writing the script which you can test from the command line.

Once that's working the second part is how to create an icon on the desktop that will open a terminal, run the script and leave the terminal open (assuming you want to see the ouput from the script). This second part is harder and the specifics depend on which Desktop, which Terminal Emulator and which scripting language you are using. Which are you using? There are many scripting languages; the "obvious" choice is bash.

Well, what I'm trying to do is run PWGEN to get creative passwords. But instead of having to open a command line, think of what to type then do it.. I might as well have thought one up! so I know that the command line "sudo pwgen -n " Works. I created a link on the desktop and wrote these instructions, however Catkin you're right the terminal window does not remain open..

What's your take?

catkin 10-16-2009 01:20 AM

Quote:

Originally Posted by linux@cpu-computers.com (Post 3720893)
What's your take?

Which Desktop, which Terminal Emulator and which scripting language you are using?

linux@cpu-computers.com 11-13-2009 08:13 PM

Sorry for the delay in reply, I hope you can still answer this for me

terminal:
GNOME Terminal 2.26.3.1

desktop configuration file (application/x-desktop)
This is the file type (Shortcut from the desktop)

All I did was create a shortcut to run a command.. typed in the command as if I've opened a terminal. The command runs, than Gone.

I'm not running a script per say... Should I be?

i92guboj 11-13-2009 10:02 PM

In my humble opinion, one step at a time:
  • create the script using a text editor
  • learn how to set the execution permissions, and how to run it from the command line, just use xterm, gnome-terminal or whatever you prefer
  • after that, you can start worrying about how to create a link to it on your desktop

The tutorials above can help you with the first step, all you need is a text editor, either a graphic one or a command line text-based one, it's irrelevant as long as it can save the file as plain text.

For the second step you will want to check the man page for chmod, you can also use graphical tools. Most graphical file explorers will allow you to set the permissions of a given file.

The third step is just a matter of experimenting on your desktop to create a link to the script, most desktops show some kind of "Run on a terminal" option, which is useful for these cases. If not, it still can be done. But let's worry about that later.


All times are GMT -5. The time now is 11:56 AM.