Topic "Error executing script: what's wrong?"

Author Message
mlist
[View user's profile]

Joined: 2007-04-26
Posts: 5
I'm trying to execute a script that remotely execute a mysql dump and then get generated files but it doesn't work. I already tried different syntax but I didn't find a solution
Could someone give me a tips?

This is my script:
-----script-----
option batch on

# Disable overwrite confirmations that conflict with the previous
option confirm off

# Connect
# [(scp|sftp)://][user[:password]@]host[:port][/path/[file]] [/privatekey=key_file]
# open sftp://tmpupusr:T3mpupusr@10.39.132.150
open sftp://root:mypass@10.39.132.140

# Change remote directory
cd /usr/Backup/Mysql

# Remove old backup file
rm max_db_dump.sql.gz

# Change local directory
lcd Z:\
lcd Backup\MICSAD2

# Force binary mode transfer
option transfer binary

# Execute backup remotely
# call /usr/bin/mysqldump -uroot -hlocalhost -pmypass max > max_db_dump.sql
call /usr/bin/mysqldump -uroot -hlocalhost -pmypass max | gzip -c > max_db_dump.sql.gz

# Download file to the local directory Z:\
get max_db_dump.sql.gz

# Disconnect
close

# Exit WinSCP
exit
------end of script-----

The problem is that on remote server (10.39.132.140) mysql dump and .gz file is created correctly but an error is displayed when getting file.
It seems that winscp for some strange reason isn't able to get the file.
This is the error:
Host has not answered for more than 15 seconds. Still waiting...
Warning: Aborting this operation will close connection!
<A<bort: Abort
Terminated by user.
Session 'root@10.39.132.140' closed.
No session.
No session.
Unknown command '#close'.
Unknown command '#exit'.
winscp>

One useful thing to know in order to understand the problem is that when this error is displayed, executing "ls -lh" on remote server shows that dump file still continues to grows; thus I suspect that "get" begin before gz file is completely created. I tried to don't create a .gz file using standard mysqldump sintax (call /usr/bin/mysqldump -uroot -hlocalhost -pmypass max > max_db_dump.sql) but the problem is always the same
Obviously I have thought that I must find a way to put some sleep (although I don't know how to do it...) but I have others script that remotely create a gz file and they work perfectly.
For example I have scripts like this:
# Execute backup remotely
call sudo tar -zcvf micsad1_openads_bck_.`date +%Y%m%d`.tar.gz max/

# Download file to the local directory Z:\
get *.tar.gz

and this script work perfectly! Tar.gz file is created and THEN (after gz is finished) the get begin.
I searched on the forum problems related to "Host has not answered..." but I thing posts are related to others things...

Do you have any suggestion?
Sad
Thanks
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
mlist wrote:
One useful thing to know in order to understand the problem is that when this error is displayed, executing "ls -lh" on remote server shows that dump file still continues to grows

At that time, are the processes that create the file (mysqldump or gzip) still running?
_________________
Martin Prikryl
mlist
[View user's profile]

Joined: 2007-04-26
Posts: 5
No, no other dumps or zip commands are executed.
I'm sure about this because I'm the administrator of the server and moreover executing "ps -ax | grep mysql" or "ps ax | grep zip" or "w", the only process active is the remote script.

As explained the strange thing is that "get file" begin before the dump.tar.gz is completed. I think this could be the problem but...I don't know how TO FORCE my script to wait until dump is completed.
I'm not an expert but when I write vbscript I use for example:
command..., 0, True (that force my script to stop until command is executed.)
I think also that is necessary to know how to debug error message:
Host has not answered for more than 15 seconds. Still waiting...
Or..to know the possible reasons that cause this error.

I tried to reboot the server and I did lot of retry on windows but..nothing is changed
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
mlist wrote:
No, no other dumps or zip commands are executed.
I'm sure about this because I'm the administrator of the server and moreover executing "ps -ax | grep mysql" or "ps ax | grep zip" or "w", the only process active is the remote script.

That's what I think. I was asking whether the processes are still running when the WinSCP "call" command finishes.
_________________
Martin Prikryl
mlist
[View user's profile]

Joined: 2007-04-26
Posts: 5
prikryl, I apologize!

I didn't correctly read your question
Yes mysqldump is still running when winscp call command finish.
What can I do to force wiscp "wait" the end of mysqldump?

Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
I finally understand. The "Host has not answered for more than 15 seconds" message is not caused the by the "get" command, but rather by "call" command, because the dump takes too long. Try to set longer timeout. You would need to do that by pre-configured stored session.
_________________
Martin Prikryl
mlist
[View user's profile]

Joined: 2007-04-26
Posts: 5
I tried to increase timeout to 3600 seconds but the problem is still present

I tried with another script that execute a tar on another remoter server (increasing timeout from winscp gui to 3600) but I have the same problem.

This is my script:
-------begin script-----
option batch on


# Disable overwrite confirmations that conflict with the previous
option confirm off

# Connect
# [(scp|sftp)://][user[:password]@]host[:port][/path/[file]] [/privatekey=key_file]
# open sftp://tmpupusr:T3mpupusr@10.39.132.150
open sftp://root:mypass@10.39.131.100

# Change remote directory
cd /var/www/

# Remove old backup file
rm *.tar.gz

# Change local directory
lcd Z:\
lcd Backup\MIRHWB01

# Force binary mode transfer
option transfer binary

# Execute backup remotely
call sudo tar -zcvf mirhwb01_iad_bck_.`date +%Y%m%d`.tar.gz iad/

# Download file to the local directory Z:\
get *.tar.gz

# Disconnect
#close
----------end of script----------

This is error message:
iad/common/bin/mrtg/mrtg-check-cpu.sh
iad/common/bin/mrtg/mrtg-check-jdk-threads.sh
iad/common/bin/iad
iad/common/common.tar.gz
Host has not answered for more than 15 seconds. Still waiting...
Warning: Aborting this operation will close connection!
(A)bort: Abort
Terminated by user.
Session 'root@10.39.131.100' closed.
No session.
No session.

Please note that editing timeout setting from winscp gui show 3600 as seconds thus...it seems to ignore my setting!
Is there a way to configure it from script? I don't understand why timeout setting is ignored
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
mlist wrote:
I tried to increase timeout to 3600 seconds but the problem is still present

How have you done that? You open session 'sftp://root:mypass@10.39.131.100'. I doubt its name of the stored session, when the longer timeout may have been stored.
_________________
Martin Prikryl
mlist
[View user's profile]

Joined: 2007-04-26
Posts: 5
Hi prikryl

yes you were right! It was my mystake....now selection stored section and increasing timeout as suggested ALL MY SCRIPT WORK CORRECTLY!

Thanks for your great work!
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License