goodbyeplanet

Whats Wrong with my code? PSCP transfer folder to remote

7 posts in this topic

#1 ·  Posted (edited)

;run pscp.exe in the folder with script
RunWait("pscp.exe", "", @SW_SHOWMAXIMIZED)
sleep(5000)

;set PATH variable.  Assign path with putty.exe
RunWait("set PATH=" & @ScriptDir & "putty")
sleep(5000)

;do the final bit where directory is tranferred from local to remote
RunWait("pscp " & "-r" & "-pw" & $pass & @ScriptDir & $user & "@"  & $host & ":" & $dest )

The above runs without any error but nothing happens except some dos windows that flicker here and there but nothing is transferred.  where could i be going wrong? some pointers would be appreciated.  Thanks. P.S.  the variables are coming from an input box that assigns to declared variables. I have tested the variables with msgbox messages and they are ok.  the destination path is /documents/desktop

Edited by goodbyeplanet

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@ScriptDir & "putty")

@scriptdir Only includes a trailing backslash when the script is located in the root of a drive.

@ScriptDir & "\putty")

 

 
Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites
RunWait("pscp.exe", "", @SW_SHOWMAXIMIZED)

;set PATH variable(improved version)
EnvSet("PATH", @ScriptDir & "\putty.exe")
Local $path = EnvGet("PATH")
;test to make sure the variable has correct path
MsgBox($MB_SYSTEMMODAL, "", "The environment variable %PATH% has the value of: " & @CRLF & @CRLF & $path)
;try to copy folder
RunWait("pscp " & "-r" & "-pw" & $pass & @ScriptDir & $user & "@"  & $host & ":" & $dest )

Thanks careca.  I tried but still no luck.  I also used the above to make sure my PATH variable is ok but still no luck. One more information that I didnt give is that when I do it manually the dos command prompt should not be closed at all.  If it does then nothing works and i hv to start afresh.  If i can find some way to keep the dos window open then that might help I think.

Share this post


Link to post
Share on other sites

I'm thinking you need some spaces in the command line in the RunWait function. This is what the runwait funtion is seeing as the command to run.

Global $pass = "123456", $user = "Me", $host = "somecomputer", $dest = "someothercomputer"
;~ RunWait("pscp " & "-r" & "-pw" & $pass & @ScriptDir & $user & "@"  & $host & ":" & $dest )
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : "pscp " & "-r" & "-pw" & $pass & @ScriptDir & $user & "@"  & $host & ":" & $dest = ' & "pscp " & "-r" & "-pw" & $pass & @ScriptDir & $user & "@"  & $host & ":" & $dest & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

 

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

RunWait('"' & @ComSpec & '" /k ' & "pscp " & "-r" &" "& @ScriptDir &" "& $user & "@"  & $host & ":" & $dest )

Thank you BrewManNH.  I didnt realise it was such a small mistake.  It definitely connects now to my remote server and gives an authentication confirmation.  My problem now is that its saying no such file or directory.  I am confused about the syntax of the target folders on linux server.  currently i have tried documents/destination/   and /documents/destination but its not working.  would be great if somebody can help with syntax of the destination.  Alternatively I would alsoappreciate some pointers as to how I can put more thann one dos command in a single variable and execute the command on one dos instance.  If that is possible then I am sure all will work.  Thanks.

Edited by goodbyeplanet

Share this post


Link to post
Share on other sites

Ok thank you everybody.  All is working now.  I realised my problem was my source folder.  Its name had a space and i guess that confused linux.  Thanks for your help.   you are all stars.  Goodnight and greetings from Wales.

Share this post


Link to post
Share on other sites

I feel ashamed i didn't notice that too. XD


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now