Exemplo n.º 1
0
        public override void Execute()
        {
            if (proc == IntPtr.Zero)
            {
                var cmd = new AccessCommandPrompt();
                cmd.Perform();

                //Take the proc for ourselves... we can't just call base.Execute, as we have already cannabalized
                //  our version of AccessCommandPrompt by interfering with freeTitle.
                this.proc = cmd.Handle;
            }

            prevPrompt = this.getTitle();

            this.Run(command);

            string promptPrefix = this.getTitle().Substring("AutoShell SUB ".Length);
            int    index        = promptPrefix.IndexOf(":");

            if (index < 0)
            {
                throw new Exception("Do not know how to identify this SSH prompt, I should write code for this case so it doesn't have to crash (although it will always be less useful to not identify when the shell is reading for input");
            }
            promptPrefix = promptPrefix.Substring(0, index);
        }
Exemplo n.º 2
0
        public static void Run(this AccessCommandPrompt prompt, string command, bool dontBlock = false, Action beforeBlock = null, bool noDelay = false)
        {
            if (prompt == null)
            {
                prompt = new AccessCommandPrompt();
                prompt.Perform();
            }

            Clipboard.SetText(command + "\r\n");
            SendMessage(prompt.Handle, WM_COMMAND, PASTE_IN_COMMAND_PROMPT, 0);

            if (!noDelay)
            {
                //Wait until the command starts... because I am a bad programmer. Could totally fix this by properly
                //  talking to AutoShell, but you know... not enough time
                Thread.Sleep(100);
            }

            if (!dontBlock)
            {
                if (beforeBlock != null)
                {
                    beforeBlock();
                }

                //Poll until it is done
                while (!prompt.isFreeTitle(prompt.getTitle()))
                {
                    Thread.Sleep(50);
                }
            }
        }
Exemplo n.º 3
0
        public static void SyncFiles()
        {
            Directory.EnumerateFiles(localDirWin).ToList().ForEach(filePath =>
            {
                return;

                string text = File.ReadAllText(filePath);
                if (text.Contains("\r\n"))
                {
                    Console.WriteLine("File has windows line endings, changing to unix");
                    text = text.Replace("\r\n", "\n");
                    File.WriteAllText(filePath, text);
                }
            });

            var localPrompt = new AccessCommandPrompt().Perform();

            localPrompt.Run(
                string.Format(@"bash
eval `ssh-agent -s`
ssh-add /C/Users/quentin.brooks/.ssh/id_rsa
rsync -iva {0}/ [email protected]:{1}/
exit", localDir, uwDir));


            var waterlooPrompt = Commands.WaterlooStudentPrompt().Perform();

            waterlooPrompt.Run(string.Format(
                                   "rsync -iva {0}/ [email protected]:{1}/",
                                   uwDir,
                                   ugsterDir
                                   ));
        }
Exemplo n.º 4
0
 public static void SendSignal(this AccessCommandPrompt prompt, ConsoleCtrlEvent signal)
 {
     GenerateConsoleCtrlEvent(signal, ProcessExtensions.GetProcessByHandle(prompt.Handle).Id);
 }