Problems with script which call another file
Moderator: DosItHelp
Problems with script which call another file
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
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
Try to specify the full path to Conexion.txt
"C:\Program Files\WinSCP\winscp" /console /script="c:\path to\Conexion.txt"
"C:\Program Files\WinSCP\winscp" /console /script="c:\path to\Conexion.txt"
Re: Problems with script which call another file
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
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
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
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
DO_AT.CMD
1sthMonth.CMD
This works for me.
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
I think that scripts are not the answer to our question, right?
Re: Problems with script which call another file
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
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
Ed Dyreen wrote:
1sthMonth.CMDCode: 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
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
It's ripped out of a WORKING script.
There is nothing wrong with
(
::
echo.>nul
::^(
echo.>nul
::
echo.dude why this weird syntax.
)
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
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
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
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
Just a programming style I use
I could also use rem but I like this better
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
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
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
@alan_b
Is this ironic
Maybe, well I won't speak to you then
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