腻子从一个批处理文件和脚本? [英] putty from a batch file and a script?

查看:193
本文介绍了腻子从一个批处理文件和脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开腻子就好了一个批处理文件。
C:\\ putty.exe root@192.168.12.34 -pw boyhowdy。但是,为了使这项工作对我来说,我需要了解如何将一个命令脚本所以它会腻子工具下运行。如mount -o重新装载,RW /。或者是这个东西我可以用一个叫做PSCP工具来完成。我是一个NUBE这些工具,真正可以利用一些guideance。我有这些脚本的bunck和真的想实现自动化它们。三江源


解决方案

  1. 如果你的目标是通过远程腻子执行shell命令,你应该看看砰砰(腻子没有GUI,换句话说,一个ssh为Windows客户端),然后运用这里的标准-doc的技​​术砰砰


  2. PLINK是油灰集合的一部分,并且也从同一页腻子


  3. 如果您要执行,你就可以使用本地脚本


      

    砰砰用户@主机-m local_script.sh



  4. 有关实例。假设你在某些Windows对话框(FYI腻子套件还运行在Linux)上运行,并希望一些远程控制箱执行批处理命令,你会在本地计算机上创建一个shell脚本(比如mount.sh)并运行它像这样的:


      C:\\>类型mount.sh
    我是谁
    主机名
    / usr / sbin目录/安装-t ISO9660 -o RO的/ dev / CDROM / MNT
    / usr / sbin目录/安装| grep的MNT
    C:\\>砰砰remoteuser表@ REMOTEHOST -pw秘密-m mount.sh
    remoteuser表
    远程主机
    在/ mnt类型ISO9660(RO)的/ dev / CDROM



  5. 此外,它可能会更好您的公钥过来,让复制密码是不是在一些批处理文件codeD。


  6. 最后,要知道,在一个交互式shell进程定义并不是所有的环境变量将远程shell程序可用。您可能需要源一些配置文件脚本在脚本的开头。


I have a batch file that opens putty just fine. c:\putty.exe root@192.168.12.34 -pw boyhowdy. But to make this work for me I need to understand how to include a script of a command so it will run under the putty tool. Like mount –o remount,rw / . Or is this something I can do with a tool called pscp. I am a nube to these tools and really could use some guideance. I have a bunck of these scripts and would really like to automate them. Thankyou

解决方案

  1. If your goal is to execute shell commands remotely through putty, you should probably look at plink (putty without the gui, in other words an ssh client for windows) and then apply the standard here-doc techniques to plink.

  2. plink is part of the putty collection and is also downloadable from the same page as putty.

  3. If you want to execute a local script you would use

    plink user@host -m local_script.sh

  4. For instance. Assuming you're running on some Windows box (fyi the putty suite also runs on Linux) and want to execute a batch of commands on some remote box you would create a shell script on your local machine (say mount.sh) and run it like this:

    C:\> type mount.sh  
    whoami  
    hostname  
    /usr/sbin/mount -t iso9660 -o ro /dev/cdrom /mnt  
    /usr/sbin/mount | grep mnt  
    C:\> plink remoteuser@remotehost -pw secret -m mount.sh  
    remoteuser  
    remotehost  
    /dev/cdrom on /mnt type iso9660 (ro)
    

  5. Also, it's probably better to copy your public key over so that the password is not coded in some batch file.

  6. Finally, be aware that not all environment variable defined in an interactive shell process will be available in the remote shell process. You might need to 'source' some profile script at the beginning of your script.

这篇关于腻子从一个批处理文件和脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆