LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-24-2012, 11:30 AM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 296

Rep: Reputation: 36
automatically execute command in a new shell


Using bash is there a way to execute a command automatically in a new xterm/konsole?

Within a bash script I invoke 'konsole'. Is there a way to automatically have a command, that is passed as an argument, execute in the new konsole?

I tried using the -e option but the konsole exits as soon as the command finishes executing.
 
Old 01-24-2012, 12:03 PM   #2
sharky
Member
 
Registered: Oct 2002
Posts: 296

Original Poster
Rep: Reputation: 36
Forgot to mention; This is KDE 3.5.4

The KDE version is not my choice. It's the version mandated by IT at work.

Tried "konsole -e ls --noclose" and "konsole -e ls --hold". Neither worked. The konsole closes immediately.
 
Old 01-24-2012, 12:45 PM   #3
sharky
Member
 
Registered: Oct 2002
Posts: 296

Original Poster
Rep: Reputation: 36
Pass a function to konsole?

Example
Code:
#!/bin/bash

export VAR1=dummyvar1
export VAR2=dummyvar2

VAR_FUNC ()
{
export VAR3=dummyvar3
}

konsole -T "test_function"
In the konsole that is started from the script.

Quote:
> env | grep VAR
VAR1=dummyvar1
VAR2=dummyvar2
> VAR_FUNC
bash: VAR_FUNC: command not found
If I source the script then the function is found within the terminal where I sourced the script but the konsole that is started from the script doesn't have the function defined.

Is there a work-around for this? If so, then my original question about automatically starting a command in a new konsole is not required.

My actual need is to have the functions defined in the new konsole.

Hope this is making sense.
 
Old 01-24-2012, 01:39 PM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 241Reputation: 241Reputation: 241
Try export with -f
Code:
VAR_FUNC ()
{
export VAR3=dummyvar3
}
export -f VAR_FUNC
konsole -T "test_function"
 
Old 01-24-2012, 03:03 PM   #5
sharky
Member
 
Registered: Oct 2002
Posts: 296

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by Cedrik View Post
Try export with -f
Code:
VAR_FUNC ()
{
export VAR3=dummyvar3
}
export -f VAR_FUNC
konsole -T "test_function"
Yes!!!

thx,
 
  


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
how to execute a command automatically after resuming from suspend to RAM? bjharker Linux - General 5 11-24-2008 08:00 AM
Some Way to Execute a CGI Command Automatically des_a Programming 3 10-27-2007 06:18 PM
How to automatically execute a command (TrueCrypt) on mount cbonar Linux - General 2 08-27-2006 10:42 AM
is it possible to automatically execute a command when cd is mounted? LiquidSlumber Linux - Software 1 03-26-2006 01:18 AM
? to add a command to execute automatically when xwindows loads up Kasperisa Linux - Newbie 2 08-02-2003 10:16 AM


All times are GMT -5. The time now is 02:56 PM.

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
Open Source Consulting | Domain Registration