How do I create a directory on remote host if it doesn't exist without ssh-ing in?

后端 未结 6 2112
南笙
南笙 2021-02-01 00:57

I\'m not sure if this is possible or not. Basically, I\'m writing a script that allows me to scp a file to my hosting. This is it so far. Argument 1 is the file and argument 2 i

6条回答
  •  情书的邮戳
    2021-02-01 01:18

    This is a two step process

    ssh myusername@ssh.myhost.net "mkdir -p $2"
    

    This ensures directory structure is created. Then, you copy

    scp $1 myusername@ssh.myhost.net:$2
    

提交回复
热议问题