Remotely Executing Shell Script - Problems


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remotely Executing Shell Script - Problems
# 1  
Old 04-09-2014
Remotely Executing Shell Script - Problems

Hey Lads,

I have a shell script on a remote Server X that i need to execute from Server A. the script executes fine locally but remotely does not. It appears the script on the remote machine is calling another shell script which only has an array defined . Please see below the errors.

Code:
#remote_Script.sh

host=("1.2.3.4")

. another_script.sh

echo "executing"

for in in "${host[@]}"
do
echo $i"Hello World"
done

Code:
#another_script.sh

host=("1.1.1.1" "2.2.2.2" "3.3.3.3")

The command i'm using to execute the remote script.

Code:
ssh -qt root@X '/path/to/remotescript/remote_Script.sh'

Here is the output i get
Code:
/path/to/remotescript/remote_Script.sh : another_script.sh: No such file or directory. 

executing
1.2.3.4Hello World

Instead of printing the I.P's present in another_script.sh, its printing the entries in the array "host". how do i get around this?
# 2  
Old 04-09-2014
Use a full path to the another_script.sh, inside the remote_script.
This User Gave Thanks to blackrageous For This Post:
# 3  
Old 04-09-2014
thanks for the reply but the script another_script.sh has permission 640 and i don't have privileges to change them. I've already tried giving the full path, since no one has execute permission it errors out.
# 4  
Old 04-09-2014
You show that you are logging in as the root user. Who owns the file?
Why not just read the contents of that second script file and merge it into the one script. You're sourcing that script to save environment variable content. What does your system administrator think of this issue?
This User Gave Thanks to blackrageous For This Post:
# 5  
Old 04-09-2014
couple of questions:
  1. is 'another_script' residing in the same dir as the 'remote_script.sh'? If not, can its location be determined relative of the location of the 'remote_script.sh'?
  2. Do you have the liberty of changing the 'remote_script.sh'?
This User Gave Thanks to vgersh99 For This Post:
# 6  
Old 04-09-2014
Hi Vgersh99

to answer your question

1. its in the same directory as the remote script.
2. although i'm a root user i cannot change the permission because the script is source controlled and against policy to change permission.

Thanks
# 7  
Old 04-09-2014
if the script is not executable, what exactly is the purpose of the script?
If you cannot modify a 'remote_script.sh', I don't think there's much you can do....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problems executing an interactive shell script

I am new to Unix shell and to this forum. I am having some trouble executing an interactive shell script that I have written using Mac TextEdit that takes a user input via terminal of a file type (jpg or gif) and then activates a script that will iterate through a folder of unsorted file types... (4 Replies)
Discussion started by: Braveheart
4 Replies

2. Shell Programming and Scripting

List and copy dir remotely using shell script

Hi, I am looking for a way to copy the directory on a remote machine that's present on the same remote machine. ex. I have multiple directories on a remote machine "B" created as /abc/LOG_1004 /abc/LOG_1008 /abc/LOG_1012 The script should be able to create a copy of the latest dirs... (1 Reply)
Discussion started by: deo_kaustubh
1 Replies

3. Shell Programming and Scripting

Executing a shell script using sh

Platform : Solaris 10, RHEL 5.4, OEL 6 I've noticed that some of my colleagues execute scripts by typing sh before the script name sh myscript.shI always execute a script by typing the script name and typing enter provided PATH variable has . (current directory) in it myscript.sh (and... (1 Reply)
Discussion started by: John K
1 Replies

4. Solaris

how to execute shell script present in unix machine remotely from windows

how to execute shell script present in unix machine remotely from windows? I having a shell script in my unix machine, need to execute the script remotely from my windows machine using Visual Basic or VBA macros. Thanks In Advance. --Suresh (1 Reply)
Discussion started by: sureshmani
1 Replies

5. Homework & Coursework Questions

Problems executing script

Hi, I'm a complete novice to Linux and UNIX. I'm having trouble getting a script to execute properly. I did a similar script earlier in the semester with no problems. For whatever reason I can't get this one to work. Any help would be greatly appreciated as I'm completely lost and frustrated at... (5 Replies)
Discussion started by: Lindy70
5 Replies

6. Shell Programming and Scripting

Problems with remotely executing scripts

Hi, in the below command, i export a value to a variable which later is used by the script, however i dont see the exported value is actually been exported. ssh user@host "export var=/path/ ; cd /path/ ; ./script" how can i use the above command with proper value of var remotley (7 Replies)
Discussion started by: suraj.sheikh
7 Replies

7. HP-UX

Remotely connecting to HP-UX poses a lot of problems

1)MY HP-UX11iv2 machine is on a specific subnet as in rrr.rr.199.( its a rp3410 blade server).It has 2 hard disks one of them has HP-UX11iv2 and the other hard disk is not being used 2)ip of the hp-ux machine is rrr.rr.199.rrr 3)i need to access this hp-ux machine remotely from a windows machine... (3 Replies)
Discussion started by: rookie8278
3 Replies

8. Shell Programming and Scripting

Remotely executing awk command

ssh user@machine awk '{ split ($1,ar,"!");print ar}' samp >samp1 Error: Unmatched '. However on <machine> awk '{ split ($1,ar,"!");print ar}' samp >samp1 executes successfully. Any suggestions. (1 Reply)
Discussion started by: bishweshwar
1 Replies

9. Shell Programming and Scripting

Executing remotely the script

Hi All, I have a script to be executed in another machine. I connect to that machine from another server as a root ( this is the only configured access, as i cannot log in as a normal user). After that I have to switch to a normal user and that I can be able to executge that script. But all this... (12 Replies)
Discussion started by: elthox
12 Replies

10. UNIX for Advanced & Expert Users

Shell script is not executing

Hi, I am trying to execute the below shell script: script name(ss1). ss1 was given permission - 744 before executing. name: ss1 #ss1 #usage:ss1 ls who pwd :wq I tried to execute $ss1 (Enter) Its not executing.... It says that ss1 is not found: echo $SHELL. The o/put i got is... (5 Replies)
Discussion started by: dreams5617
5 Replies
Login or Register to Ask a Question