Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
|
 |
08-30-2005, 07:45 PM
|
#1
|
Member
Registered: Apr 2005
Location: Chicago, IL
Distribution: openSUSE 13.1
Posts: 357
Rep:
|
making a script that opens terminal and enter commands into that terminal
Is there a way to make a script that opens your terminal and enters a series of commands (like mkdir, chown, etc) into that terminal?
|
|
|
09-01-2005, 04:54 AM
|
#2
|
Member
Registered: Nov 2003
Location: Mestre - ITALY
Distribution: Debian sarge
Posts: 132
Rep:
|
it is possible to make a script that performs directly the commands you have to enter in a console. Can you be more specific  ? What do you have to do with this script?
|
|
|
09-03-2005, 12:23 PM
|
#3
|
Member
Registered: Apr 2005
Location: Chicago, IL
Distribution: openSUSE 13.1
Posts: 357
Original Poster
Rep:
|
Quote:
Originally posted by mrosati
it is possible to make a script that performs directly the commands you have to enter in a console. Can you be more specific ? What do you have to do with this script?
|
Because I'm a lazy fool, I wanted to make a script that would open a terminal and enter some of the commands, or a series of commands, that I enter a lot. That's all.
|
|
|
09-03-2005, 01:01 PM
|
#4
|
Member
Registered: Nov 2003
Location: Mestre - ITALY
Distribution: Debian sarge
Posts: 132
Rep:
|
a script is a list of commands for a shell. you can do 2 things:
1) edit your script. no matter what you write in it, just write your command-list correctly.
2) the script must now be "chmoded" as executable (chmod 755 <scriptname>)
3) now run your script, you can do this in 2 ways:
3.1) double click your script icon (kde)
3.2) from a shell, simply (./<scriptname, supposing your working directory is the same where the script is located)
it is not useful (either i don't know if it is possible) to make a script that runs a shell and then "puts" a sequence of commands in it. all these tasks are performed simply by the script.
if you want to be helped in writing the script you can ask me everything you want.
|
|
|
12-15-2008, 04:31 AM
|
#5
|
LQ Newbie
Registered: Dec 2008
Posts: 2
Rep:
|
Quote:
Originally Posted by mrosati
a script is a list of commands for a shell. you can do 2 things:
1) edit your script. no matter what you write in it, just write your command-list correctly.
2) the script must now be "chmoded" as executable (chmod 755 <scriptname>)
3) now run your script, you can do this in 2 ways:
3.1) double click your script icon (kde)
3.2) from a shell, simply (./<scriptname, supposing your working directory is the same where the script is located)
it is not useful (either i don't know if it is possible) to make a script that runs a shell and then "puts" a sequence of commands in it. all these tasks are performed simply by the script.
if you want to be helped in writing the script you can ask me everything you want.
|
Hello,
I would want to write a script which open a new terminal and here , in the new terminal opened, to login using ssh on other machine. Do you think that it is possible?
Thank you,
Iulia
|
|
|
12-15-2008, 10:45 AM
|
#6
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
That entirely depends on the terminal you use.
There's no easy way to just "dump" commands into a terminal.
However, most terminals can use -e to run a given script. So, my advice would be to save the commands you want to write into a shell script, then chmod u+x it, and then you can just do this
Code:
xterm -e /path/to/yourscript.sh
|
|
|
12-15-2008, 12:49 PM
|
#7
|
Senior Member
Registered: Dec 2005
Distribution: Slackware
Posts: 1,135
|
Quote:
Originally Posted by julia79
Hello,
I would want to write a script which open a new terminal and here , in the new terminal opened, to login using ssh on other machine. Do you think that it is possible?
Thank you,
Iulia
|
Sure it is:
Code:
xterm -e ssh <remote_machine>
Depending on how you've setup ssh, you'll either now be logged into the remote_machine, or you'll have a terminal with a prompt for username/password on the remote.
If you want it scripted
Code:
#!/bin/bash
#open new terminal window with ssh login to machine_name
Terminal -e ssh <remote_machine>
cheers,
|
|
|
12-15-2008, 01:23 PM
|
#8
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Quote:
Originally Posted by mrclisdue
If you want it scripted
Code:
#!/bin/bash
#open new terminal window with ssh login to machine_name
Terminal -e ssh <remote_machine>
cheers,
|
I'd rather alias it. I am reluctant to make a script for a oneliner unless I have a good reason to.
You can alias it and put it into ~/.bashrc and/or ~/.bash_profile (or whatever the rc files for your shell are). For bash it would be like:
Code:
alias xssh='xterm -e ssh user@host'
If you need to parametrize you can use a function instead
Code:
function xssh() {
xterm -e ssh "$1"
}
Then use it from bash like this
|
|
|
12-16-2008, 10:34 AM
|
#9
|
LQ Newbie
Registered: Dec 2008
Posts: 2
Rep:
|
Quote:
Originally Posted by mrclisdue
Sure it is:
Code:
xterm -e ssh <remote_machine>
Depending on how you've setup ssh, you'll either now be logged into the remote_machine, or you'll have a terminal with a prompt for username/password on the remote.
If you want it scripted
Code:
#!/bin/bash
#open new terminal window with ssh login to machine_name
Terminal -e ssh <remote_machine>
cheers,
|
Thank you very much. It was very helpfully for me.
Have a gread day,
Iulia
|
|
|
All times are GMT -5. The time now is 05:13 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
|
|