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 |
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.
|
 |
09-03-2004, 01:13 AM
|
#1
|
LQ Newbie
Registered: May 2004
Location: France
Distribution: fresh Ubuntu
Posts: 21
Rep:
|
xterm - howto lauch an xterm into a specific directory
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 ?
|
|
|
Click here to see the post LQ members have rated as the most helpful post in this thread.
|
09-03-2004, 05:41 AM
|
#2
|
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802
Rep:
|
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".
|
|
|
09-03-2004, 05:44 AM
|
#3
|
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802
Rep:
|
As for running as a specific user, you should use the su command to change user id.
|
|
|
09-03-2004, 06:45 PM
|
#4
|
LQ Newbie
Registered: May 2004
Location: France
Distribution: fresh Ubuntu
Posts: 21
Original Poster
Rep:
|
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 06:47 PM.
|
|
|
09-03-2004, 07:15 PM
|
#5
|
Member
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438
Rep:
|
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/
|
|
|
09-03-2004, 08:54 PM
|
#6
|
LQ Newbie
Registered: May 2004
Location: France
Distribution: fresh Ubuntu
Posts: 21
Original Poster
Rep:
|
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)
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 09:38 PM.
|
|
|
02-14-2008, 10:31 PM
|
#7
|
LQ Newbie
Registered: Jul 2003
Distribution: Kubuntu 7.10 Gutsy Gibbon
Posts: 10
Rep:
|
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
|
|
|
02-18-2008, 05:04 AM
|
#8
|
LQ Newbie
Registered: Jul 2003
Distribution: Kubuntu 7.10 Gutsy Gibbon
Posts: 10
Rep:
|
Anyone...?
|
|
|
02-26-2008, 03:18 PM
|
#9
|
LQ Newbie
Registered: Feb 2008
Posts: 1
Rep:
|
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>
|
|
3 members found this post helpful.
|
01-27-2023, 09:49 AM
|
#10
|
LQ Newbie
Registered: Dec 2017
Posts: 13
Rep: 
|
Quote:
Originally Posted by virtual_void
This is how you launch xterm into directory <dir>
# xterm -e 'cd <dir> && /bin/bash'
|
You are the man !
__________________________
Yes, this thread is 15 years old and dormant; but today it was very timely and relevant to me.
|
|
|
01-27-2023, 10:23 AM
|
#11
|
Senior Member
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 4,029
|
Quote:
Originally Posted by 789
Yes, this thread is 15 years old and dormant; but today it was very timely and relevant to me.
|
The thread was relevant but not timely to you. The warning is about whether your reply would be timely and relevant to other people. A vague expression of congratulation towards a long inactive account is neither.
Quote:
Please note that this thread has not been replied to in over 6 months. Please ensure your reply is still relevant and timely.
|
|
|
|
01-30-2023, 04:45 AM
|
#12
|
LQ Newbie
Registered: Jan 2023
Posts: 1
Rep:
|
You can launch an xterm terminal into a specific directory using the following command:
xterm -cd /path/to/directory
Replace "/path/to/directory" with the actual path to the directory you want to launch the xterm terminal in. This will open an xterm terminal in the specified directory, allowing you to run commands and navigate the file system from that location.
|
|
|
All times are GMT -5. The time now is 08:45 PM.
|
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
|
|