synchronizing codes between Windows and Linux

本文介绍了一种使用Python结合pscp命令从Windows系统向Linux服务器(如Ubuntu)上传代码的方法,避免了传统手动上传的繁琐与低效。通过编写Python脚本,实现了自动化代码同步,提高了开发效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When we overhaul some codes in source insight,we wanna modify them to understand their meaning.If codes are run in Linux(e.g.,Ubuntu),we need to upload or synchronize them to remote server by Winscp,a visual tools,which is cumbersome and low efficient.Therefore,I develop a python program with pscp command from Winscp,which partly refers to the blog

synchronize codes

We can use command as follow to upload codes from Windows to Linux:

pscp Windows_local_path username@Linux_server'IP:/remote_path

it is similar to the command SCP for transferring files between Linux.

python program is shown as follow:

import os
srcpath = os.path.join(os.getcwd(),r"sda9.txt")
dstpath = r"/home/f2fs/test/strace"
cmd = "pscp -l f2fs -pw root " + srcpath + " f2fs@192.168.40.146:" + dstpath
os.system(cmd)
print("success")

在这里插入图片描述

Appendix

C:\Users\Administrator\Desktop>pscp
PuTTY Secure Copy client
Release 0.70
Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -p        preserve file attributes
  -q        quiet, don't show statistics
  -r        copy directories recursively
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -P port   connect to specified port
  -l user   connect with specified username
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for user authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -hostkey aa:bb:cc:...
            manually specify a host key (may be repeated)
  -batch    disable all interactive prompts
  -proxycmd command
            use 'command' as local proxy
  -unsafe   allow server-side wildcards (DANGEROUS)
  -sftp     force use of SFTP protocol
  -scp      force use of SCP protocol
  -sshlog file
  -sshrawlog file
            log protocol details to a file
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值