RFE: Change directory when opening PuTTY session
would it be possible to set the current directory in PuTTY to that one opened in WinSCP?
Lars
Advertisement
Advertisement
Suggestions are welcome.
How to implement that technically. I'm not aware of any reliable solution. See discussions in threads linked from tracker.Suggestions on what aspect?
Advertisement
set WINSCP_FNAME=$HOME/.winscptargetdir if ( -f $WINSCP_FNAME) then cd `cat $WINSCP_FNAME` rm -f $WINSCP_FNAME endif
echo !/ > ~/.winscptargetdir
if [ -f $HOME/pwdputtyscript.sh ] then source $HOME/pwdputtyscript.sh cd $WINSCP rm -f $HOME/pwdputtyscript.sh fi
echo WINSCP=!/ > ~/pwdputtyscript.sh
Advertisement
if [ -f $HOME/pwdputtyscript.sh ] then source $HOME/pwdputtyscript.sh cd $PUTTYSTARTDIR rm -f $HOME/pwdputtyscript.sh fi
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Diagnostics; namespace WinSCPPutty { class Program { static void Main(string[] args) { //args = [user pass host dir] string user, pass, host, dir; if (args.Length < 3) return; if (args.Length < 4) dir = "~"; user = args[0]; pass = args[1]; host = args[2]; dir = args[3]; try { string puttyexe = @"C:\Program Files (x86)\PuTTY\putty.exe"; //you'll need to edit the putty location as needed string filename = System.IO.Path.GetTempPath() + "cdputty.txt"; string txt = "echo PUTTYSTARTDIR=" + dir + " > ~/pwdputtyscript.sh"; string logintxt = user + "@" + host + " -pw " + pass; File.WriteAllText(filename, txt); ProcessStartInfo ps = new ProcessStartInfo(puttyexe, logintxt + " -m \"" + filename + "\""); ps.WindowStyle = ProcessWindowStyle.Hidden; Process p = Process.Start(ps); p.WaitForExit(); File.Delete(filename); Process.Start(puttyexe, logintxt); } catch (Exception) { } } } }
Thanks for sharing this!I wrote a little c# app to help with this, if anybody is interested.
%ProgramFiles%\PuTTY\putty.exe -t -m "%TEMP%\putty.txt" !`cmd.exe /c echo cd "!/" ; $($SHELL) > "%TEMP%\putty.txt"`
cd "/home/user"; $($SHELL)
That page only copies WinSCP documentation:I have found this page where it is solved: <removed by admin>
Advertisement
You can post new topics in this forum