making a script that opens terminal and enter commands into that terminal
Linux - GeneralThis 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.
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.
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?
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.
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.
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?
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
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>
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.