Copy and run that script in Remote server

Hi All,

I need script to perform below task.

  1. I have a script in one server and need to copy this script to remote server
  2. login in to remote server
  3. run the script which i copied to this server.
#!/bin/bash
read a
scp /tmp/script.sh user@hostname:/tmp
ssh user@$a
./scirpt.sh

Here the problem is i dnt have root access for this server, when i copied files to the remote server the file permission is only read only access so i have to change the file permission and run the script in remote server automatically when i run the scripts.

Note: i can have root access if i run the command "admin". admin is executable command file which is stored some location in server.

Thanks

try with this:

rcp /tmp/script.sh user@hostname:/tmp
rsh hostname -l user sh /tmp/script.sh

 
#!/bin/bash
echo "Enter script name:"
read script
# you should be in the cur dir of the script
scp $script user@hostname:/tmp
# check the access mode to the script
ssh user@@hostname ls -ltr /tmp/$script
# add execution permission to the script
ssh user@@hostname chmod +x /tmp/$script
# Run it
ssh user@hostname /tmp/$script