LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-12-2009, 04:52 PM   #1
linux@cpu-computers.com
LQ Newbie
 
Registered: Oct 2009
Location: Ontario Canada
Distribution: Kubuntu 9.04 Desktop
Posts: 14

Rep: Reputation: 0
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.
 
Old 10-12-2009, 04:55 PM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
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."
 
Old 10-12-2009, 05:43 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Here's another good tutorial: http://rute.2038bug.com/index.html.gz
 
Old 10-13-2009, 01:32 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by linux@cpu-computers.com View Post
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.
 
Old 10-15-2009, 05:53 PM   #5
linux@cpu-computers.com
LQ Newbie
 
Registered: Oct 2009
Location: Ontario Canada
Distribution: Kubuntu 9.04 Desktop
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
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?
 
Old 10-16-2009, 01:20 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by linux@cpu-computers.com View Post
What's your take?
Which Desktop, which Terminal Emulator and which scripting language you are using?
 
Old 11-13-2009, 08:13 PM   #7
linux@cpu-computers.com
LQ Newbie
 
Registered: Oct 2009
Location: Ontario Canada
Distribution: Kubuntu 9.04 Desktop
Posts: 14

Original Poster
Rep: Reputation: 0
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?
 
Old 11-13-2009, 10:02 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox Scripting Add-on (Scripting HTML / Javascript inside Firefox) linuxbeatswindows Programming 1 09-18-2009 10:09 PM
Scripting mickeyd531 Linux - Newbie 1 05-10-2009 08:05 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Need help scripting Tamara Programming 1 06-05-2005 03:18 PM
Scripting Askari Programming 1 12-09-2003 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration