Jump to content

[SOLVED]@WorkingDir and path containing spaces


schmelle
 Share

Recommended Posts

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]

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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]

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...