Loading ...
Sorry, an error occurred while loading the content.
 

Unable to read remote files using pscp (VIM 7.2)

Expand Messages
  • Aman Jain
    Hi, I am using Vim 7.2 on windows. I tried to open a remote file using :Nread scp://aman@lnx-server//ws/aman/test.c But I am getting this error...
    Message 1 of 8 , Jun 28, 2009
      Hi,

      I am using Vim 7.2 on windows.
      I tried to open a remote file using ":Nread scp://aman@lnx-server//ws/aman/test.c"

      But I am getting this error...

      C:\WINDOWS\system32\cmd.exe /c "c:\\aman\\sw\\pscp.exe" -q -batch
      "aman@lnx-server:/ws/aman/test.c" "C:\DOCUME~1\aman\LOCALS~1\Temp
      \VIA217.c"
      The filename, directory name, or volume label syntax is incorrect.
      shell returned 1
      Hit any key to close this window...

      The problem seems to be that the argument to pscp.exe i.e
      username@server:/path is surrounded by quotes.
      If I manually try to copy this file to a temporary location, it works
      fine.

      Now, I found people talking about removing single quotes from
      netrw.vim, but unfortunately that's for vim 7.0 (http://vim.wikia.com/
      wiki/Using_PuTTY_pscp_with_Vim)

      Here are the relevant lines form my netrw.vim, please suggest how to
      proceed:
      821: exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport."
      ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape
      (tmpfile,1)
      1187: exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport."
      ".shellescape(tmpfile,1)." ".shellescape
      (g:netrw_machine.":".b:netrw_fname,1)
      4820: exe s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape
      (useport,1)." ".filelist." ".shellescape(tgtdir,1)
      5100: exe s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape
      (useport,1)." ".args." ".shellescape(machine.":".tgt,1)

      TIA
      Aman Jain
      India

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Charles Campbell
      ... It looks like you re using the cmd.exe shell. You might try ... and see if that fixes the problem. If it does, presumably something is setting your shell
      Message 2 of 8 , Jun 29, 2009
        Aman Jain wrote:
        > Hi,
        >
        > I am using Vim 7.2 on windows.
        > I tried to open a remote file using ":Nread scp://aman@lnx-server//ws/aman/test.c"
        >
        > But I am getting this error...
        >
        > C:\WINDOWS\system32\cmd.exe /c "c:\\aman\\sw\\pscp.exe" -q -batch
        > "aman@lnx-server:/ws/aman/test.c" "C:\DOCUME~1\aman\LOCALS~1\Temp
        > \VIA217.c"
        > The filename, directory name, or volume label syntax is incorrect.
        > shell returned 1
        > Hit any key to close this window...
        >
        > The problem seems to be that the argument to pscp.exe i.e
        > username@server:/path is surrounded by quotes.
        > If I manually try to copy this file to a temporary location, it works
        > fine.
        >
        > Now, I found people talking about removing single quotes from
        > netrw.vim, but unfortunately that's for vim 7.0 (http://vim.wikia.com/
        > wiki/Using_PuTTY_pscp_with_Vim)
        >
        It looks like you're using the cmd.exe shell. You might try

        :set shq=

        and see if that fixes the problem. If it does, presumably something is
        setting your shell quoting character. To find out more about it,

        :verbose set shq?

        should tell you the current value and where it was last changed.

        Regards,
        Chip Campbell


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Aman Jain
        shq is already blank in my gvim, and I am getting the same error. So can you suggest some other alternative?
        Message 3 of 8 , Jun 29, 2009
          shq is already blank in my gvim, and I am getting the same error.
          So can you suggest some other alternative?
          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Charles Campbell
          ... Read ... and send me a copy of the debugging output. If you use ftp, please elide any passwords first. Please do a minimal number of steps to elicit the
          Message 4 of 8 , Jun 29, 2009
            Aman Jain wrote:
            > shq is already blank in my gvim, and I am getting the same error.
            > So can you suggest some other alternative?
            >
            Read

            :help netrw-debug

            and send me a copy of the debugging output. If you use ftp, please
            elide any passwords first. Please do a minimal number of steps to
            elicit the problem -- that'll help keep clutter down.

            Regards,
            Chip Campbell


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Aman Jain
            On Jun 30, 12:56 am, Charles Campbell ... Decho Tab C: Program Files Vim vim72 autoload netrw.vim ... doing autoload/netrw.vim
            Message 5 of 8 , Jun 29, 2009
              On Jun 30, 12:56 am, Charles Campbell <Charles.E.Campb...@...>
              wrote:
              > Aman Jain wrote:
              > > shq is already blank in my gvim, and I am getting the same error.
              > > So can you suggest some other alternative?
              >
              > Read
              >
              >   :help netrw-debug
              >
              > and send me a copy of the debugging output.  If you use ftp, please
              > elide any passwords first.  Please do a minimal number of steps to
              > elicit the problem -- that'll help keep clutter down.
              >
              > Regards,
              > Chip Campbell

              Here's the debug output:

              ---------
              Decho Tab C:\Program Files\Vim\vim72\autoload\netrw.vim
              ---------
              doing autoload/netrw.vim version v132
              ssh is not executable
              netrw#NetrwSavePosn() {
              |netrw#NetrwRestorePosn() a:0=0 winnr=1 line=1 col=1 hline=1 {
              ||restore window: exe silent! 1wincmd w
              ||restore topofscreen: exe norm! 1G0z
              ||restore posn: exe norm! 1G01|
              ||return netrw#NetrwRestorePosn }
              |return netrw#NetrwSavePosn : winnr=1 line=1 col=1 hline=1 }
              netrw#NetRead(mode=1,...) a:0=1 v132 {
              |s:NetrwOptionSave(vt<w:>) win#1 buf#1<> {
              ||w:netrw_optionsave doesn't exist
              ||fo=tcq acd=0
              ||return s:NetrwOptionSave : win#1 buf#1 }
              |s:NetrwSafeOptions() win#1 buf#1<> {
              ||window's ft=
              ||fo=nroql2 acd=0
              ||return s:NetrwSafeOptions }
              |readcmd<r> ichoice=1
              |s:GetTempfile(fname<>) {
              ||tmpfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.tmp> : from tempname()
              ||tmpfile<C:/DOCUME~1/aman/LOCALS~1/Temp/VIA1C.tmp> : chgd any \ -> /
              ||tmpfile<C:/DOCUME~1/aman/LOCALS~1/Temp/VIA1C.tmp> s:netrw_tmpfile<C:/
              DOCUME~1/aman/LOCALS~1/Temp/VIA1C.tmp>
              ||o/s dependent fixed tempname<C:\DOCUME~1\aman\LOCALS~1\Temp
              \VIA1C.tmp>
              ||ro=0 ma=1 mod=0 wrap=1
              ||return s:GetTempfile <C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.tmp> }
              |no lastfile: choice<scp://aman@lnx-server//ws/aman/test.c>
              |choice<scp://aman@lnx-server//ws/aman/test.c>
              |NetrwMethod(a:choice<scp://aman@lnx-server//ws/aman/test.c>) {
              ||determine method:
              ||scp://...
              ||a:choice <scp://aman@lnx-server//ws/aman/test.c>
              ||b:netrw_method <4>
              ||g:netrw_machine<aman@lnx-server>
              ||g:netrw_port <>
              ||b:netrw_fname </ws/aman/test.c>
              ||return NetrwMethod : b:netrw_method=4 }
              |s:GetTempfile(fname</ws/aman/test.c>) {
              ||tmpfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.tmp> re-using
              ||using fname</ws/aman/test.c>'s suffix
              ||suffix<.c>
              ||chgd tmpfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C> (removed any .tmp
              suffix)
              ||chgd tmpfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c> (added .c
              suffix) netrw_fname</ws/aman/test.c>
              ||ro=0 ma=1 mod=0 wrap=1
              ||return s:GetTempfile <C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c> }
              |checking if NetrwBrowse() should handle choice<scp://aman@lnx-server//
              ws/aman/test.c> with netrw_list_cmd<>
              |read via scp (method #4)
              |exe s:netrw_silentxfer.!"c:\\aman\\sw\\pscp.exe" -q -batch "aman@lnx-
              server:/ws/aman/test.c" "C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c"
              |NetrwGetFile(readcmd<r>,tfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c>
              method<4>) {
              ||rfile<>
              ||s:FileReadable(fname<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c>) {
              |||return s:FileReadable 0 }
              ||ro=0 ma=1 mod=0 wrap=1
              ||tfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c> not readable
              ||netrw#ErrorMsg(level=1 msg<file <C:\DOCUME~1\aman\LOCALS~1\Temp
              \VIA1C.c> not readable> errnum=9) g:netrw_use_errorwindow=1 {
              |||level=**warning** (netrw)
              |||s:winBeforeErr=1
              |||create a NetrwMessage buffer window
              |||setlocal ma noro
              |||wrote msg<**warning** (netrw) file <C:\DOCUME~1\aman\LOCALS~1\Temp
              \VIA1C.c> not readable> to NetrwMessage win#2
              |||return netrw#ErrorMsg }
              ||return NetrwGetFile : tfile<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c>
              not readable }
              |s:FileReadable(fname<C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c>) {
              ||return s:FileReadable 0 }
              |s:NetrwOptionRestore(vt<w:>) win#2 buf#3 {
              ||ro=1 ma=0 mod=0 wrap=1
              ||return s:NetrwOptionRestore : w:netrw_optionsave doesn't exist }
              |return netrw#NetRead :5 getcwd<C:\Documents and Settings\aman> }
              netrw#NetrwRestorePosn() a:0=0 winnr=-1 line=-1 col=-1 hline=-1 {
              |restore window: exe silent! 1wincmd w
              |restore topofscreen: exe norm! 1G0z
              |restore posn: exe norm! 1G01|
              |return netrw#NetrwRestorePosn }
              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Charles Campbell
              ... [snip] ... [snip] I ve included two items that seem off to me. The first one, ssh is not executable , is due to g:netrw_list_cmd not holding a string
              Message 6 of 8 , Jun 30, 2009
                Aman Jain wrote:
                >
                > On Jun 30, 12:56 am, Charles Campbell <Charles.E.Campb...@...>
                > wrote:
                >
                >> Aman Jain wrote:
                >>
                >>> shq is already blank in my gvim, and I am getting the same error.
                >>> So can you suggest some other alternative?
                >>>
                >> Read
                >>
                >> :help netrw-debug
                >>
                >> and send me a copy of the debugging output. If you use ftp, please
                >> elide any passwords first. Please do a minimal number of steps to
                >> elicit the problem -- that'll help keep clutter down.
                >>
                >> Regards,
                >> Chip Campbell
                >>
                >
                > Here's the debug output:
                >
                > ssh is not executable
                >
                [snip]
                > |exe s:netrw_silentxfer.!"c:\\aman\\sw\\pscp.exe" -q -batch "aman@lnx-server:/ws/aman/test.c" "C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c"
                >
                [snip]

                I've included two items that seem off to me. The first one, "ssh is not
                executable", is due to
                g:netrw_list_cmd

                not holding a string describing an executable. I'm not a pscp user
                myself, but :help netrw-p8 discusses some ways folks have used to
                provide an ssh for windows. I myself use cygwin.

                Now, the second item is involved in your current issue.

                exe -- that's ok

                s:netrw_silentxfer -- that's a bug with my usage of Decho; I'll fix that
                to show what's _in_ s:netrw_silentxfer rather than the fact that its in
                use. This is just a reporting problem, and doesn't affect your issue.

                "c:\\aman\\sw\\pscp.exe" -- those double quotes should not be there.
                What exactly do you use to initialize g:netrw_scp_cmd , presumably in
                your .vimrc? netrw doesn't use shellescape() to process the string in
                this variable.

                -q -batch -- that's ok AFAIK

                "aman@lnx-server..." : again, under windows, those double quotes are
                problematic (if I recall correctly). Try :echo shellescape("some
                string",1) and see what shows up. Under linux, I get 'some string'
                . (I'm not near a Windows box at the moment )

                Regards,
                Chip Campbell


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Aman Jain
                On Jun 30, 6:37 pm, Charles Campbell ... I got it working!! This was in my vimrc if ($OS =~ Windows ) let
                Message 7 of 8 , Jul 1, 2009
                  On Jun 30, 6:37 pm, Charles Campbell <Charles.E.Campb...@...>
                  wrote:
                  > Aman Jain wrote:
                  >
                  > > On Jun 30, 12:56 am, Charles Campbell <Charles.E.Campb...@...>
                  > > wrote:
                  >
                  > >> Aman Jain wrote:
                  >
                  > >>> shq is already blank in my gvim, and I am getting the same error.
                  > >>> So can you suggest some other alternative?
                  >
                  > >> Read
                  >
                  > >>   :help netrw-debug
                  >
                  > >> and send me a copy of the debugging output.  If you use ftp, please
                  > >> elide any passwords first.  Please do a minimal number of steps to
                  > >> elicit the problem -- that'll help keep clutter down.
                  >
                  > >> Regards,
                  > >> Chip Campbell
                  >
                  > > Here's the debug output:
                  >
                  > > ssh is not executable
                  >
                  > [snip]
                  > > |exe s:netrw_silentxfer.!"c:\\aman\\sw\\pscp.exe" -q -batch "aman@lnx-server:/ws/aman/test.c" "C:\DOCUME~1\aman\LOCALS~1\Temp\VIA1C.c"
                  >
                  > [snip]
                  >
                  > I've included two items that seem off to me.  The first one, "ssh is not
                  > executable", is due to
                  >   g:netrw_list_cmd
                  >
                  > not holding a string describing an executable.  I'm not a pscp user
                  > myself, but  :help netrw-p8  discusses some ways folks have used to
                  > provide an ssh for windows.  I myself use cygwin.
                  >
                  > Now, the second item is involved in your current issue.
                  >
                  > exe  -- that's ok
                  >
                  > s:netrw_silentxfer -- that's a bug with my usage of Decho; I'll fix that
                  > to show what's _in_ s:netrw_silentxfer rather than the fact that its in
                  > use.  This is just a reporting problem, and doesn't affect your issue.
                  >
                  > "c:\\aman\\sw\\pscp.exe" -- those double quotes should not be there.  
                  > What exactly do you use to initialize g:netrw_scp_cmd , presumably in
                  > your .vimrc?  netrw doesn't use shellescape() to process the string in
                  > this variable.
                  >
                  > -q -batch  -- that's ok AFAIK
                  >
                  > "aman@lnx-server..."  : again, under windows, those double quotes are
                  > problematic (if I recall correctly).  Try     :echo shellescape("some
                  > string",1)  and see what shows up.  Under linux, I get  'some string'  
                  > .  (I'm not near a Windows box at the moment )
                  >
                  > Regards,
                  > Chip Campbell

                  I got it working!!

                  This was in my vimrc
                  if ($OS =~ "Windows")
                  let g:netrw_scp_cmd="\"c:\\amajain\\sw\\pscp.exe\" -q -batch"
                  endif

                  Now I changed those extra quotes, around c:\\amajain\\sw\\pscp.exe\
                  Now the vimrc entry looks like
                  if ($OS =~ "Windows")
                  let g:netrw_scp_cmd="\c:\\amajain\\sw\\pscp.exe\ -q -batch"
                  endif

                  Bye the way are you Dr.Chip?
                  I am honored to have discussed this issue with you.

                  Thanks a lot!!
                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Charles Campbell
                  ... Great -- I m glad you found the problem! Yes, I am Dr. Chip -- thank you. Regards, Chip Campbell --~--~---------~--~----~------------~-------~--~----~
                  Message 8 of 8 , Jul 1, 2009
                    Aman Jain wrote:
                    > I got it working!!
                    >
                    > This was in my vimrc
                    > if ($OS =~ "Windows")
                    > let g:netrw_scp_cmd="\"c:\\amajain\\sw\\pscp.exe\" -q -batch"
                    > endif
                    >
                    > Now I changed those extra quotes, around c:\\amajain\\sw\\pscp.exe\
                    > Now the vimrc entry looks like
                    > if ($OS =~ "Windows")
                    > let g:netrw_scp_cmd="\c:\\amajain\\sw\\pscp.exe\ -q -batch"
                    > endif
                    >
                    > Bye the way are you Dr.Chip?
                    > I am honored to have discussed this issue with you.
                    >
                    > Thanks a lot!!
                    >
                    Great -- I'm glad you found the problem! Yes, I am Dr. Chip -- thank you.

                    Regards,
                    Chip Campbell


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.