Skip to main content
added 6 characters in body
Source Link
RatDon
  • 311
  • 2
  • 4
  • 15

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference.With &&, generally after executing gedit, it'll be sent to background and prompt will come. But I'm not getting the prompt after gedit. (Though whatever there in the next line is getting executed. Like if I put echo "Hello"echo "Hello", it's displaying helloHello.)

What's wrong here? Is there any other method? I want to do a SSH and execute some command through shell script. But I don't want to logout after the shell script finishes its execution. I want to logout manually after executing some of my own commands which are not repetitive like the above script.

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference.With &, generally after executing gedit, it'll be sent to background and prompt will come. But I'm not getting the prompt after gedit. (Though whatever there in the next line is getting executed. Like if I put echo "Hello", it's displaying hello.)

What's wrong here? Is there any other method? I want to do a SSH and execute some command through shell script. But I don't want to logout after the shell script finishes its execution. I want to logout manually after executing some of my own commands which are not repetitive like the above script.

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference.With &, generally after executing gedit, it'll be sent to background and prompt will come. But I'm not getting the prompt after gedit. (Though whatever there in the next line is getting executed. Like if I put echo "Hello", it's displaying Hello.)

What's wrong here? Is there any other method? I want to do a SSH and execute some command through shell script. But I don't want to logout after the shell script finishes its execution. I want to logout manually after executing some of my own commands which are not repetitive like the above script.

added 505 characters in body
Source Link
RatDon
  • 311
  • 2
  • 4
  • 15

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference.With &, generally after executing gedit, it'll be sent to background and prompt will come. But I'm not getting the prompt after gedit. (Though whatever there in the next line is getting executed. Like if I put echo "Hello", it's displaying hello.)

What's wrong here? Is there any other method? I want to do a SSH and execute some command through shell script. But I don't want to logout after the shell script finishes its execution. I want to logout manually after executing some of my own commands which are not repetitive like the above script.

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference. What's wrong here? Is there any other method?

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference.With &, generally after executing gedit, it'll be sent to background and prompt will come. But I'm not getting the prompt after gedit. (Though whatever there in the next line is getting executed. Like if I put echo "Hello", it's displaying hello.)

What's wrong here? Is there any other method? I want to do a SSH and execute some command through shell script. But I don't want to logout after the shell script finishes its execution. I want to logout manually after executing some of my own commands which are not repetitive like the above script.

Source Link
RatDon
  • 311
  • 2
  • 4
  • 15

shell scripting remote commands through ssh

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some search, I'm able to execute some codes like:

File: ssh.sh

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c
EOF

But I don't see any difference if I put like:

ssh -X [email protected] << EOF
cd /root/myDir
gedit a.c b.c &
EOF

The & doesn't make any difference. What's wrong here? Is there any other method?