Bash Script Error Catching

前端 未结 3 1700
庸人自扰
庸人自扰 2021-02-05 16:28

I am very new to bash scripts, and for my first script attempt I am submitting files to my professor\'s dropbox within the same server.

The code is this:



        
3条回答
  •  逝去的感伤
    2021-02-05 17:02

    echo "Submit lab$1?"
    
    read choice
    
    echo "Send to Prof's dropbox"
    cp -rv /path/to/lab$1 /path/to/dropbox &>/dev/null
    
    [ $? -eq 0 ] && { #success, do something } || { #fail, do something }
    

    And so on...

提交回复
热议问题