Sign in to follow this  
Followers 0
schmelle

[SOLVED]@WorkingDir and path containing spaces

5 posts in this topic

#1 ·  Posted (edited)

Hi all,

I'm trying to simulate a puTTY session with plink.exe. It works fine if the path to plink.exe does not contain any spaces.

If the path contain any spaces I got an "File not found" error. Does anybody has an idea how to avoid this using the @WorkingDir macro?

$Connection = Run(@WorkingDir&"\"&$plink_exe&" -ssh -auto_store_key_in_cache -l "&$UserI&" -pw "&$PassI&" "&$HostI, @WorkingDir,@SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD)

Thanks and best regards

schmelle

P.S.: I'm using plink.exe from QuestpuTTY which supports the parameter "-auto_store_key_in_cache".

Edited by schmelle

[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites



Why are you adding the working dir? I would expect that to be redundant and would think you could only use $plink_exe for the programname.

The normal option I would go for when it is needed is to surround the programname with DoubleQuotes and probably in this case also use @comspec.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi Jos,

thanks for your reply.

I'm not exaktly sure what you mean with your first sentence. My problem is that I don't know where the user will store the script. The location of the script (and plink.exe) can contain spaces...

I've modified the script as you requestet to:

$Connection = Run(@ComSpec&" /c "&@WorkingDir&"\Data"&"\plink.exe"&" -ssh -auto_store_key_in_cache -l "&$UserI&" -pw "&$PassI&" "&$HostI, @WorkingDir,@SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD)

Same Problem. If the location of plink.exe contains a space, plink.exe won't be found (and not started).

schmelle


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I do not understand why @workdir is needed as that is already the current directory so this:

@WorkingDir&"\Data"&"\plink.exe"

should be the same as:

"plink.exe"

When you do need the whole path I would add double quotes around it like:

$Connection = Run(@ComSpec & ' /c "' & @WorkingDir & '\Data\plink.exe" -ssh -auto_store_key_in_cache -l ' & $UserI & ' -pw ' & $PassI & ' ' & $HostI, @WorkingDir, @SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD)
Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi Jos,

great! :)

It's working as expected!

Now I understand what you meant and modified the string a little bit to match your first sentence:

$Connection = Run(@ComSpec&" /c "&".\Data\plink.exe"&" -ssh -auto_store_key_in_cache -l "&$UserI&" -pw "&$PassI&" "&$HostI, @WorkingDir,@SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD)

Thanks for your help

schmelle


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

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
Sign in to follow this  
Followers 0