LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 04-19-2004, 05:49 AM   #1
Meriadoc
Member
 
Registered: Apr 2004
Location: Netherlands
Distribution: Mandrake 10.1
Posts: 43

Rep: Reputation: 15
executing konsole from shell script


I'm making the transition from Windows to Linux (Mandrake 9.2). Right now I'm trying to make a script I can doubleclick from my linux desktop that opens a console window (konsole) and then issues a command (defined in the script) to this window. In Win(DOS) this would require a batch file with a wait statement (to prevent the command prompt from closing after the command was issued). In Linux my script works if I type it from within an active Konsole session, but if I click a link from the desktop, or click the file name within its directory from Konqueror nothing seems to happen. If I make the script executable I get the error 'Couldn't find the program <myscriptname.sh>'.

Is what I'm trying possible from a script or am I taking the wrong approach?
 
Old 04-19-2004, 06:00 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
Type man konsole or read the available HTML documentation for it. Most or all xshells support a switch for executing a program within the xshell. aterm -e irssi will for instance launch an aterm with the irssi IRC client, and when irssi exits, the shell closes.

If you are creating a shellscript you need the first line to be #!/bin/bash or #!/bin/sh to indicate you want bash to interpret it, that's why you get the "Can't find..." error.


Håkan
 
Old 04-19-2004, 06:46 AM   #3
Meriadoc
Member
 
Registered: Apr 2004
Location: Netherlands
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
Thanks for the quick help, but I'm afraid I do not quite understand your answer. Perhaps my question was a bit to vague. The script I've written looks as follows:

#!/bin/bash/
cd /home2/ut2004/System
ucc-bin server <long list of parameters>

if I execute this script from the console it works fine, if I execute it from a link within the KDE desktop it doesn't work because the console won't open. Is there a way to get the console to open, or is this impossible?
 
Old 04-19-2004, 07:11 AM   #4
Jelle
Member
 
Registered: Feb 2004
Location: Utrecht, The Netherlands
Distribution: Debian
Posts: 79

Rep: Reputation: 15
yes there is, but do you need the console to be open? do you need to interact with this ucc-bin server thing?

Method one would be to copy a icon from your toolbar, right-click on it and change all the properties to the one you need. (or right-click on the desktop and select create new:file:link to application) Open program in konsole should be one of them.

The other way is to call konsole directly in your script like this:
konsole --vt_sz 80x40 -e telnet $ip &
which opens a new konsole and telnets into the appropriate host.
(BTW never use telnet when you don't absolutely have to, use shh instead)

check with kde if it will actually execute shellscripts and not just open them in a textviewer.
 
Old 04-19-2004, 07:39 AM   #5
Meriadoc
Member
 
Registered: Apr 2004
Location: Netherlands
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
Ah thanks Jelle that did the trick.

(for those who care) My final script looks like this:

#!/bin/sh
konsole --vt_sz 80x40 -noclose --workdir /home2/ut2004/System/ -e ucc-bin <long list of parameters>

- e executes my ucc-bin file
- noclose prevents the console from shutting down
- workdir makes sure ucc-bin can find the other files it needs while running

I placed the file in the System directory and created a link to the desktop to start it. It works perfectly now. I need the console to remain open because the 'ucc-bin server thing' runs a dedicated game server as long as it is open, which I can terminate by closing the console (so without a console that remains open, the server closes down directly after starting it (at least I think it does))

thanks for the help
 
Old 01-31-2006, 11:29 PM   #6
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Rep: Reputation: 15
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?

Pls help me.

Thanks.

Last edited by shandy^^^; 01-31-2006 at 11:30 PM.
 
Old 02-01-2006, 04:06 AM   #7
sohny
Member
 
Registered: Aug 2004
Location: bangalore
Distribution: Redhat,Ubuntu
Posts: 64

Rep: Reputation: 15
Y dont u try this

konsole --vt_sz 80x40 -noclose --workdir /etc/file/ -e ./file2
 
Old 02-01-2006, 09:32 AM   #8
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Rep: Reputation: 15
Quote:
Originally Posted by sohny
Y dont u try this

konsole --vt_sz 80x40 -noclose --workdir /etc/file/ -e ./file2
i have tried this already then it is still the same it would popup a blank konsole without prompt.

I found out that the 'konsole' will let you open a new konsole/terminal.
 
Old 06-02-2009, 08:56 AM   #9
shaharh
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
Another konsole question

I'd like to open a konsole, execute command and then leave it opened with shell.
So, if I use:
konsole -noclose -e date
I'm left with the konsole opened but with no sell/prompt.
Anyone can help ?
 
Old 06-30-2009, 08:47 AM   #10
shaharh
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
Unhappy

Quote:
Originally Posted by shaharh View Post
I'd like to open a konsole, execute command and then leave it opened with shell.
So, if I use:
konsole -noclose -e date
I'm left with the konsole opened but with no sell/prompt.
Anyone can help ?
How do I get help around here ???
 
Old 07-10-2009, 08:08 AM   #11
CodeJuggler
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
Hello shaharh,

Try this:

Code:
konsole --noclose -e bash --login
see "man bash" for the details
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 12:33 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 05:40 AM
Auto-Executing Shell Script on boot benrose111488 Linux - Software 5 12-18-2004 12:52 AM
executing shell script on apache nooodles Linux - General 1 06-29-2004 01:51 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 09:10 PM


All times are GMT -5. The time now is 08:58 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration