Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use scp command to realize file upload code in Shell

Shulou Source: shulou.com Published: 2022-06-03 09:24:43 10月23日 Update

This article mainly explains "how to use the scp command in Shell to achieve file upload code", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use the scp command in Shell to achieve file upload code" bar!

PS: Ant and Phing users, you can ignore it. I just like playing Shell.

The code is as follows:

#! / bin/sh

HOME='/cygdrive/d/public_html/myproject'

# # package the local code first

# # exclude the following files: * .svn, * .bat, upload.sh, cache

# # if you need a large number of exclude files, you can use the parameter-exclude-from=FILE

# # write the file line by line into FILE

Cd $HOME

Tar jcf tmp.tar.bz2 *\

-- exclude=*.bat\

-- exclude=*.bz2\

-- exclude=*.gz\

-- exclude=.svn\

-- exclude=cache\

-- exclude=upload.sh\

# # uploading Files via SCP

Scp tmp.tar.bz2 user@your.host.com:/home/public_html/myproject/tmp.tar.bz2

# # execute remote ssh commands

# # another script load.sh is executed here

Ssh user@your.host.com

"

Cd / home/public_html/myproject

Tar jxf tmp.tar.bz2

Chown-R web:web *

Chmod-R 755 *

Sh load.sh

Rm-f tmp.tar.bz2

"

# # deleting local files

Rm-f tmp.tar.bz2

Echo "Everything is done."

# Monday, January 11, 2010 by Verdana

# vim: set expandtab tabstop=4 shiftwidth=4:

Thank you for your reading, these are the contents of "how to use scp commands in Shell to achieve file upload code". After the study of this article, I believe you have a deeper understanding of how to use scp commands in Shell to achieve file upload code, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files code commands learning content one line parameters just that is ideas situations articles weeks more users knowledge knowledge points articles scripts follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB Apple Shulou Technology Huawei