Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report