LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 08-30-2005, 07:45 PM   #1
Cinematography
Member
 
Registered: Apr 2005
Location: Chicago, IL
Distribution: openSUSE 13.1
Posts: 357

Rep: Reputation: 31
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?
 
Old 09-01-2005, 04:54 AM   #2
mrosati
Member
 
Registered: Nov 2003
Location: Mestre - ITALY
Distribution: Debian sarge
Posts: 132

Rep: Reputation: 15
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?
 
Old 09-03-2005, 12:23 PM   #3
Cinematography
Member
 
Registered: Apr 2005
Location: Chicago, IL
Distribution: openSUSE 13.1
Posts: 357

Original Poster
Rep: Reputation: 31
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.
 
Old 09-03-2005, 01:01 PM   #4
mrosati
Member
 
Registered: Nov 2003
Location: Mestre - ITALY
Distribution: Debian sarge
Posts: 132

Rep: Reputation: 15
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.
 
Old 12-15-2008, 04:31 AM   #5
julia79
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by mrosati View Post
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
 
Old 12-15-2008, 10:45 AM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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
 
Old 12-15-2008, 12:49 PM   #7
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware
Posts: 1,134

Rep: Reputation: 277Reputation: 277Reputation: 277
Quote:
Originally Posted by julia79 View Post
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,
 
Old 12-15-2008, 01:23 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by mrclisdue View Post
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

Code:
xssh user@host
 
Old 12-16-2008, 10:34 AM   #9
julia79
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by mrclisdue View Post
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
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminal opens to ~/Desktop General Linux - Software 1 11-05-2005 05:00 PM
can't enter text in terminal lpn1160 Linux - General 4 11-04-2005 02:39 AM
Starting a program so it opens in a new terminal dangerousdave Linux - Newbie 1 03-24-2005 04:26 PM
Help to create a script to open a terminal and run commands in it. Brian1 Linux - Software 6 02-07-2005 06:46 PM
terminal no longer opens in FC3 hywaydave Linux - Software 1 01-11-2005 04:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:33 PM.

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