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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-12-2002, 04:45 PM
|
#1
|
Member
Registered: Mar 2002
Location: Lausanne, Switzerland
Distribution: Mandriva 2007.0
Posts: 233
Rep:
|
console commands as script?
I'm looking to write command line commands as a script to be executed by launching the file from an icon or double click etc. Do I need to look at .sh files and bash?
I'm thinking about saving energy on launching programs with Wine.
|
|
|
06-12-2002, 04:56 PM
|
#2
|
Member
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590
Rep:
|
Ok, this is easy. First make your shellscript file:
-- start --
#!/bin/sh
# This is a comment because the line starts with a hash
[your commands here]
-- end --
Say that file was called foo.sh, now do:
chmod +x foo.sh
You can now run foo.sh just like a normal executable.
Alex
|
|
|
06-12-2002, 06:16 PM
|
#3
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
incidentally you don't need to call it something.sh. that's only an occasional convention. you'd be suprised how many commands you use are actaully just script files. also you don't need to use the #!/bin/sh line either, as that is the default used to interpret a script file, but that is a good habit to get into tho.
|
|
|
06-13-2002, 09:28 AM
|
#4
|
LQ Guru
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613
Rep:
|
Ok, so I would just open an editor and type
mplayer -[options]
and make it executable and that's it? It seems like a symlink would be more appropriate then? What am I missing? Obviously I am just trying to read into this ain't I.
|
|
|
06-13-2002, 09:38 AM
|
#5
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
you can't make a symlink including options. you presumably mean making an alias. it all depends what you want to do with a scripts as to how much goes into it. you COULD have a script that just did that but it'd be a bit pointless.
|
|
|
06-13-2002, 04:20 PM
|
#6
|
Member
Registered: Mar 2002
Location: Lausanne, Switzerland
Distribution: Mandriva 2007.0
Posts: 233
Original Poster
Rep:
|
Thanks for your comments guys, I'm going to look at this over the weekend.
|
|
|
01-31-2006, 11:38 AM
|
#7
|
LQ Newbie
Registered: Jan 2006
Posts: 26
Rep:
|
I want to make script where when it will be click it will issue a command in the terminal. the file is a perl file. what shall i do?
pls help me.
thanks
|
|
|
01-31-2006, 12:16 PM
|
#8
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Quote:
Originally Posted by rooman
I'm looking to write command line commands as a script to be executed by launching the file from an icon or double click etc. Do I need to look at .sh files and bash?
I'm thinking about saving energy on launching programs with Wine.
|
Writing shell scripts has little to do with running programs on Wine....
Shell scripts operate at the shell-level, and are barely above assembly language.
Wine is for running high-level Windows apps on Linux.
Go to www.tldp.org and get the "Bash Guide for Beginners" by Machtelt Garrels
|
|
|
01-31-2006, 12:16 PM
|
#9
|
Member
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282
Rep:
|
First, you're better off starting your own thread that jumping on the end of someone else's, for a variety of reasons (including that threads with no replies get auto-bumped and thus more attention)...
Secondly, your description is a little vague. You're talking about terminals and clicking on things in the same context, whereas they're usually pretty separate. If you click on something, it's usually up to the Window Manager to decide what to do in that situation based on a variety of things, so it depends which WM is running and what it's looking for. Generally when the WM decides to do something based on a GUI event, it won't direct the output to a particular terminal since any xterm (for example) that you launch is just its own program sitting on the desktop. You can probably instruct it to run the program in a terminal, but I'm second-guessing you here...
Let's start again. You have a perl file. How is it you expect the user to start it running (clicking on it or issuing a console command), and what output do you want to happen (and where)?
|
|
|
01-31-2006, 12:21 PM
|
#10
|
Member
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282
Rep:
|
Quote:
Originally Posted by pixellany
Writing shell scripts has little to do with running programs on Wine....
|
Yes. In this instance, you probably are better off with an alias if all you want to do is shorten the command to, say, 'cs' instead of giving all the arguments to launch wine running Counter-Strike. However, if there's certain environment variables you need to set, other pre-launch things to be done (especially if only under certain conditions) then a shell script may earn its keep.
Quote:
Originally Posted by pixellany
Shell scripts operate at the shell-level, and are barely above assembly language.
|
Oooh... I wouldn't quite go that far. That's like saying that working from a console is barely above feeding machine code instructions to the processor by hand...
|
|
|
02-01-2006, 12:30 AM
|
#11
|
LQ Newbie
Registered: Jan 2006
Posts: 26
Rep:
|
Hello.
I tried the konsole command like I have a
--------------
#file1
#!/bin/sh
konsole --vt_sz 80x40 -noclose --workdir /etc/file/ -e file2
--------------
#file2
#!/bin/sh
echo "Hello! This should display"
--------------
chmod +x file1
chmod +x file2
./file1
After ./file1 a blank terminal/konsole would just popup.
am i doing it right? I want that the when i do the ./file1 it would display on the terminal ka output of file2. is posible?
Whats the use of this line "konsole --vt_sz 80x40 -noclose --workdir /etc/file/ -e file2" ?
Pls help me.
Thanks.
Last edited by shandy^^^; 02-01-2006 at 12:31 AM.
|
|
|
02-01-2006, 04:31 AM
|
#12
|
Member
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282
Rep:
|
I'm not really sure what those arguments do (perhaps Virtual Terminal size = 80 by 40 pixels, don't close on exit, work in the /etc/file directory and execute 'file2'?) - but will tell you for sure. My guess as to why the second script isn't running is the --workdir /etc/file; perhaps the konsole is starting up in that directory, so it tries to look there for file2? You could try fully qualifying the filename (e.g. ~/test/file2 instead). Just to check, are there any messages at all on the new konsole or does it just go straight to a prompt?
(I have ideas of getting this to work involving creating a new user specially and playing with their ~/.bashrc files. I know it's actually crazy, but it's always nice to know how you can connect up your toolkit in Linux... )
|
|
|
02-01-2006, 07:22 AM
|
#13
|
LQ Newbie
Registered: Jan 2006
Posts: 26
Rep:
|
Im using Fedora Core 4 and it cant locate the manual for konsole.
In the new konsole it is only blank and there is no prompt.
|
|
|
02-01-2006, 08:57 AM
|
#14
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Quote:
Originally Posted by Dtsazza
Oooh... I wouldn't quite go that far. That's like saying that working from a console is barely above feeding machine code instructions to the processor by hand...
|
I am aware that I spoke imprecisely...the sense of my comment was that shell programming can involve some pretty crude, non-intuitive syntax. A long series of nested sed commands, for example, will be absolutely incomprehensible to the average programmer.
Like C, shell programming takes you closer to the guts than some other languages. But, yes, its not the same as assembler....
|
|
|
02-02-2006, 08:49 PM
|
#15
|
LQ Newbie
Registered: Jan 2006
Posts: 26
Rep:
|
I tried the konsole command and this script but it would just popup a new blank terminal :
#!/bin/bash
konsole --noclose -e echo_args Hello, thanks for using Konsole!
the other terminal it would display like this:
[root@client1 sample]# ./file1
Uh oh.. can't get terminal attributes..
|
|
|
All times are GMT -5. The time now is 03:49 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|