LinuxQuestions.org
Have you heard the LinuxQuestions.org Podcast?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 09-03-2004, 02:13 AM   #1
jobano
LQ Newbie
 
Registered: May 2004
Location: France
Distribution: fresh Ubuntu
Posts: 21
Thanked: 0
xterm - howto lauch an xterm into a specific directory


[Log in to get rid of this advertisement]
hello,

I would like to launch an xterm from my file manager, I'm able to get the directory but not to launch an xterm prompting at this directory... you know ?
should not be so geeky, I will be shamy

thanks in advance


PS: in the same kind of idea, how can I launch something as a specific user into a root owned script ?
jobano is offline     Reply With Quote
Old 09-03-2004, 06:41 AM   #2
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,800
Thanked: 0
If you are using Konqueror to browse with then it's easy, just "right-click" on the folder and select "Actions" and then select "Open terminal here".
/bin/bash is offline     Reply With Quote
Old 09-03-2004, 06:44 AM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,800
Thanked: 0
As for running as a specific user, you should use the su command to change user id.
/bin/bash is offline     Reply With Quote
Old 09-03-2004, 07:45 PM   #4
jobano
LQ Newbie
 
Registered: May 2004
Location: France
Distribution: fresh Ubuntu
Posts: 21
Thanked: 0

Original Poster
thanks for your help, but it's not so obvious
I perhaps was not clear enough but I need to script that !

to run an xterm at a specific directory, I tried (as script run by clicking on a directory into the file manager)
Code:
dir=$@
cd $dir
xterm &         <---- this xterm will always be in my home directory
or
Code:
dir=$@
xterm -e "cd $dir"    <---- this xterm flash and never wait for me

and to run a program hold by a specific using a script launched by root...
Code:
echo user: $USER
su jobano
echo user: $USER       <------- obviously this command wait the sub-shell logout ; please help

I really need someone's help on that because finding documentation on so precise points is a bit complex
Yours sincerely.

Last edited by jobano; 09-03-2004 at 07:47 PM..
jobano is offline     Reply With Quote
Old 09-03-2004, 08:15 PM   #5
idaho
Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438
Thanked: 0
When you open an xterm window, you are effectively logging in. Therefore an xterm session will always start at your home directory. You can use expect:
(http://expect.nist.gov/)
to pass commands to the xterm session after you start it. Changing to your desired directory after you have launched xterm would be covered by this.

To run a root owned script as a non root user you can use sudo:
http://www.courtesan.com/sudo/
idaho is offline     Reply With Quote
Old 09-03-2004, 09:54 PM   #6
jobano
LQ Newbie
 
Registered: May 2004
Location: France
Distribution: fresh Ubuntu
Posts: 21
Thanked: 0

Original Poster
Quote:
Originally posted by idaho
When you open an xterm window, you are effectively logging in. Therefore an xterm session will always start at your home directory. You can use expect


I have found another tip, not perfect but does the trick for me
Code:
#!/bin/bash
clic=$@
if [ -d $clic ]; then
	dir=$clic
else
	dir="`dirname \"$clic\"`/"
fi
xterm -e "cd $dir && sudo su $USER" &
my shell is a sub-shell of another but I don't care (the parent kill itself instantly when I come back on it)


Quote:
Originally posted by idaho
To run a root owned script as a non root user you can use sudo:
http://www.courtesan.com/sudo/
It was the inverse I wanted, but I've found !
Code:
echo user: $USER
su -c 'echo user: $USER' jobano
That does the trick,
thanks, you were quick, that's nice !

Last edited by jobano; 09-03-2004 at 10:38 PM..
jobano is offline     Reply With Quote
Old 02-14-2008, 11:31 PM   #7
jayanth
LQ Newbie
 
Registered: Jul 2003
Distribution: Kubuntu 7.10 Gutsy Gibbon
Posts: 10
Thanked: 0
Question Getting the Prompt After 'xterm -e <command>'

Hi,

I'm trying to do something similar, that is, running a command automatically after launching an xterm window using the 'e' switch. Something like:

xterm -e "ls"

The problem is that this causes the xterm window to run the command and get destroyed, that is, the command prompt is not available. But when I run the command

xterm -e "ls && sudo su"

the window stays open and xterm's command prompt is available for further use. But this is not what I want.

How do I get the window to stay open and also get the command prompt available (the 'hold' switch does the former, but not the latter)?

Thanks,

Jayanth
jayanth is offline  
Tag This Post ,
Reply With Quote
Old 02-18-2008, 06:04 AM   #8
jayanth
LQ Newbie
 
Registered: Jul 2003
Distribution: Kubuntu 7.10 Gutsy Gibbon
Posts: 10
Thanked: 0
Anyone...?
jayanth is offline     Reply With Quote
Old 02-26-2008, 04:18 PM   #9
virtual_void
LQ Newbie
 
Registered: Feb 2008
Posts: 1
Thanked: 0
This is how you launch xterm into directory <dir>

# xterm -e 'cd <dir> && /bin/bash'

this is how you would do it with konsole
# konsole --workdir <dir>
virtual_void is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
initial directory in xterm walt Linux - Newbie 3 05-29-2006 05:49 PM
xterm default home directory Fritz_Monroe Linux - Newbie 2 08-05-2005 02:33 PM
how is black xterm background in IceWM when issue a xterm command? BRAHmS Linux - Software 1 02-14-2005 04:51 AM
xterm newbiejon Linux - Software 3 12-29-2004 12:00 AM
Xterm does not start in root directory mystique98ls Linux - Newbie 2 12-14-2004 06:45 PM


All times are GMT -5. The time now is 01:04 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration