Page 1 of 2
Problems with script which call another file
Posted: 13 Apr 2010 15:36
by rabantot
Hello,
I would appreciate you guys could help me with this little problem.
I have a application called WinSCP in order to download some files to one LAN server from another server (located in my DMZ).
In order to automate the download process I created two files:
The first one is a *.cmd file that calls some connection parameters from the second one (a *.txt file)
They're as follows:
file1.cmd
-------------------------------------------------------------
"C:\Program Files\WinSCP\winscp" /console /script=Conexion.txt
-------------------------------------------------------------
Conexion.txt
-------------------------------------------------------------
open
sftp://User1:Password@192.168.1.10:22 -privatekey=pelim.ppk
option transfer ascii
cd /home
synchronize local "C:\Program Files\WinSCP\Files" /home
close
exit
-------------------------------------------------------------
Whenever I executed the file1.cmd manually, it works normally. But when I try to execute it from a scheduled task, it doesn't work and I can see the scheduled task to be running for the eternity.
How can I do in order to make ir works fime from the schedule task?
Regards,
Rabantot
Re: Problems with script which call another file
Posted: 13 Apr 2010 15:59
by !k
Try to specify the full path to Conexion.txt
"C:\Program Files\WinSCP\winscp" /console /script="c:\path to\Conexion.txt"
Re: Problems with script which call another file
Posted: 14 Apr 2010 12:02
by rabantot
I just tried putting the complete path to the Conexion.txt file and the results are the same. Or Could you please suggest me another way to put the files together and manages to use the WinSCP commands without incompatibility problems???
Thank you very much
Regards,
Rabantot
!k wrote:Try to specify the full path to Conexion.txt
"C:\Program Files\WinSCP\winscp" /console /script="c:\path to\Conexion.txt"
Re: Problems with script which call another file
Posted: 18 May 2011 10:02
by crr
Hi Rabantot,
I am having the same problem you have, exatly the same
have you by any chance found the solution?
any body can help us here?
If not, is there any comand line software to SCP files from a windows server to other boxes?
thanks in advance for your replies
Re: Problems with script which call another file
Posted: 18 May 2011 11:02
by Ed Dyreen
DO_AT.CMD
Code: Select all
set "FullPath.SOURCE=!FullPath.PRGM3TH!\SYS\CFG\SchTasks"
set "?=1sthMonth.CMD" &set /p "?= :/ !?! "<nul
::(
at 00:00 /interactive /every:1 "!FullPath.SOURCE!\!?!"
::)
set "?=Saturday.CMD" &set /p "?= :/ !?! "<nul
::(
at 00:00 /interactive /every:za "!FullPath.SOURCE!\!?!"
::)
1sthMonth.CMD
Code: Select all
set "FullPath=!Drive.PRGM3TH!\SYS\CFG\SchTasks\1sthMonth"
::
Pushd "!FullPath!\" &&(
::
for /f "tokens=*" %%! in (
'2^>nul dir /a:-d /b "*.CMD"'
) do (
set "File=%%!"
set "FullPathFile=!FullPath!\!File!"
::
echo. &set /p "?= :/ !File!..." <nul
::^(
start "!File!" /low /wait "!FullPathFile!"
::
set /p "?= [OK]" <nul &echo.
::^)
echo.>nul
)
::
popd
)
This works for me.
Re: Problems with script which call another file
Posted: 19 May 2011 01:55
by crr
I think that scripts are not the answer to our question, right?
Re: Problems with script which call another file
Posted: 19 May 2011 06:04
by Ed Dyreen
Then I don't understand the question, I thought a method was needed to schedule a task that wouldn't hang when launched by the scheduler.
Re: Problems with script which call another file
Posted: 19 May 2011 06:50
by Ed Dyreen
You are not the only one, i've had the same problem I believe. In my case it had to do with who launched the process. But I don't really remember so I stop here
Re: Problems with script which call another file
Posted: 19 May 2011 12:42
by alan_b
Ed Dyreen wrote:1sthMonth.CMD
Code: Select all
) do (
set "File=%%!"
set "FullPathFile=!FullPath!\!File!"
::
echo. &set /p "?= :/ !File!..." <nul
::^(
start "!File!" /low /wait "!FullPathFile!"
::
set /p "?= [OK]" <nul &echo.
::^)
echo.>nul
)
This works for me.
Are you sure ?
I always expect grief from a label within parenthesis,
so I would expect surprises are imminent with 4 sets of double colon
:: .
Regards
Alan
Re: Problems with script which call another file
Posted: 19 May 2011 13:13
by Ed Dyreen
I am not going to discuss the syntax, people asking me wy do you put this in parenthesis or that it isn't necesarry..., it's only a piece of the code.
I am not going to solve a problem it is meant as a hint nomore than that.
I was just wondering how @rabantot scheduled these tasks.
@alan_b
I always expect grief from a label within parenthesis,
It's ripped out of a WORKING script.
There is nothing wrong with
(
::
echo.>nul
::^(
echo.>nul
::
echo.dude why this weird syntax.
)
Re: Problems with script which call another file
Posted: 19 May 2011 14:10
by jeb
alan_b wrote:Are you sure ?
I always expect grief from a label within parenthesis,
Ed Dyreen wrote:It's ripped out of a WORKING script.
You are right, both.
: and :: are allowed in parenthesis, but not at any line and not in any combination.
Somewhere I have posted a complete explanation at
lingubender rem vs ::jeb
Re: Problems with script which call another file
Posted: 20 May 2011 10:56
by alan_b
Thanks, I have learnt something new today.
Please explain the purpose of these ::
Are they simply a complicated way of inserting almost blank "white space" between lines of CMD code without breaking the code,
or do they modify the execution of the code,
and I need to use WinSCP to see the difference with and without the ::
Regards
Alan
Re: Problems with script which call another file
Posted: 20 May 2011 11:20
by Ed Dyreen
Just a programming style I use
Code: Select all
:Label "( /Str: "String|Byval" /Optional )"
::
:: This does nothing
SetLocal
::(
::Open a subject
::(
echo.Hi. My Name is.. ED
::)
::that's no subject
::(
echo.realy?>nul
::)
::
(
endlocal
seterror
)
goto :eof ()
::)
I could also use rem but I like this better
Re: Problems with script which call another file
Posted: 20 May 2011 13:12
by alan_b
Nearly 3 decades ago my very first P.C. had the luxury of a 20 MB HDD.
As a result I developed a frugal programming style
Abraham Lincoln advocated my preferred programming style when he said :-
"Better to remain silent and be thought a fool than to speak out and remove all doubt."
I respect your capability,
but for me to use these double colon tricks would be venturing beyond my capabilities,
and I would fall flat on my face.
Regards
Alan
Re: Problems with script which call another file
Posted: 20 May 2011 13:15
by Ed Dyreen
@alan_b
I respect your capability,
but for me to use these double colon tricks would be venturing beyond my capabilities,
and I would fall flat on my face.
Is this ironic
"Better to remain silent and be thought a fool than to speak out and remove all doubt."
Maybe, well I won't speak to you then