1834339 Members
1962 Online
110066 Solutions
New Discussion

starting a script

 
SOLVED
Go to solution
Maciej Szewczykowski
Frequent Advisor

starting a script

hi all,
i'd like to ask for help in the following matter:
i have a script that contains several standard commands. among them there is a command that is supposed to start another script - it is just a name of the script that is to be initialized, actually. but it doesn't work this way.
how to make it work?
32 REPLIES 32
Pete Randall
Outstanding Contributor

Re: starting a script

Have you used the full path name to the second script?


Pete

Pete
melvyn burnard
Honored Contributor

Re: starting a script

Do you have the PATH variable set in ht script to allow the command to be "reached"? ohterwise, are you specifiying ht full pathname of the script?
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
T G Manikandan
Honored Contributor

Re: starting a script

Make sure

1.Execute permissions of the script

2.Provide the full path of the script.

Thanks
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

of course, i've given the full path and set permission properly - still nothing.
Yogeeraj_1
Honored Contributor

Re: starting a script

hi,

can you post the scripts or part of them?

caller and callee

You may wish to trace it using "echo" messages at specific parts in the code.

thanks
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Pete Randall
Outstanding Contributor

Re: starting a script

Well, of course, given the lack of info provided, we had to eliminate the obvious. Thanks for your patience. Maybe if we could see the script, we'd have more insight.


Pete

Pete
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

here goes the script - please take a look at 9th line: here is invoked the script (rem_arch) supposed to be run.
melvyn burnard
Honored Contributor

Re: starting a script

try adding the line :
set -x
to hte beginning of the script and then watch the output.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Pete Randall
Outstanding Contributor

Re: starting a script

I'm not sure what this script is doing:

$ man put
No manual entry for put.
$ man lcd
No manual entry for lcd.
$ man mget
No manual entry for mget.

Maybe some sort of ftp script, I guess? How is it invoked?

Pete

Pete
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

what does parameter -x cause?
Dario_1
Trusted Contributor

Re: starting a script

Try running the script in debug mode:

sh -x scriptname

You will the script executing every command.
DR
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

yes indeed Pete - actually it is an input file for initializing ftp connection
ftp < script
so the commands are carried out by remote host
Yogeeraj_1
Honored Contributor

Re: starting a script

hi,

This is a "debugging-tool". After this command is executed, all further commands will be
printed to the terminal before they are executed until a 'set +x'
command is found.


regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Pete Randall
Outstanding Contributor

Re: starting a script

Ok, can you tell if the mkdir and the put(s) were successful? The last line removes all the evidence so maybe if you commented it out and then checked to make sure things are as you expect.


Pete

Pete
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

thank you all.
in which line of the script command set -x should be placed?
Yogeeraj_1
Honored Contributor
Solution

Re: starting a script

hi,

if you can't mix ftp commands with shell commands!

this should provide you with some hints:

...
for i in `cat ftp.list`; do
echo "put $i"|ftp serverB
file=`basename $i .txt`
mv $i $FTP_ARCH/
done
...

hth
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

yes Pete, all the commands are successful, except the one invoking the script.
Yogeeraj_1
Honored Contributor

Re: starting a script

set -x should be place at the position from which you wish start the debugging process.

you stop with a "set +x"

hth
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)

Re: starting a script

You seem to be combining ftp and shell script commands together! You can't do that.

I'm assuming this is the command thats not working:

/usr/local/home/rainbow/archiwum/temp_arch/rem_arch


If this is on the local host (the host where ftp is being run from) then you could just add an exclamation mark at the start to run it in a shell:

!/usr/local/home/rainbow/archiwum/temp_arch/rem_arch

If this command is actually on the remote host ( the one you are ftp'ing to) then there is *no way* to run it from within ftp as it doesn't allow you to run code on the remote end.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Pete Randall
Outstanding Contributor

Re: starting a script

How about the contents of the remote script, could we see that? I'm thinking maybe it is invoked but unable to do anything for some reason. Maybe you could put a touch command in the remote script, then the existence of the "touched" file would prove that the script is being invoked.

Pere

Pete
Maciej Szewczykowski
Frequent Advisor

Re: starting a script

thanks a lot, Yogeeraj. it seems that the problem's gone.
till the next one.

Pete Randall
Outstanding Contributor

Re: starting a script

Yeah, that's where I was trying to go, Duncan - thanks. The script is never getting invoked.

Pete

Pete
Darren Prior
Honored Contributor

Re: starting a script

Hi,

Sorry to be the bearer of bad news, but you can't run shell scripts on the remote system via ftp.

The script you have supplied is a list of ftp commands and will be executed within ftp.

If you need to run the shell script on the remote system you'll need to use remsh or something similar.

regards,

Darren.
Calm down. It's only ones and zeros...
Yogeeraj_1
Honored Contributor

Re: starting a script

hi,

For running remote commands, you may consider following command will return immediately without waiting for the remote command to complete:

remsh otherhost -n "command 1>&- 2>&- &"


hth
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)