go - 一个脚本 push to aws s3 , loop, 调用系统命令 system command , int to String

访问量: 198

go

package main
import (
  "fmt"
  "os/exec"
)

func main(){
  //for i := 0; i < 1502; i++ {
  for i := 0; i < 3; i++ {
    command := "aws s3 cp --acl public-read-write nft/parachain/" + fmt.Sprintf("%v", i) + " s3://nft-data.raindrop.link/nft/parastate/" + fmt.Sprintf("%v", i)


    fmt.Println("== executing command: %s \n", command)
    // 这里每个参数都要有个空格  
// fmt.Sprintf("%v", 3) 就是把数字转换成String out, err := exec.Command("aws", "s3", "cp", "--acl", "public-read-write", "nft/parachain/" + fmt.Sprintf("%v", i), "s3://nft-data.raindrop.link/nft/parastate/" + fmt.Sprintf("%v", i)).Output() if err != nil { fmt.Printf(" ERROR: %s", err) }else{ fmt.Printf(" OK: %s", out) } } }

订阅/RSS Feed

Subscribe