UNIX ssh сценарий, выполняя команды на удаленном сервере

VARBINARY связан с 255 байтами в MySQL 5.0.2 и ниже, с 65kB в 5.0.3 и выше.

BLOB связан с 65 кБ.

В конечном счете, VARBINARY практически совпадает с BLOB (с точки зрения того, что в нем может храниться), если только вы не хотите сохранить совместимость со «старыми» версиями MySQL. Документация MySQL гласит:

В большинстве случаев вы можете рассматривать столбец BLOB как столбец VARBINARY, который может быть настолько большим, насколько вам нравится.

5
задан user123661 16 June 2009 в 13:25
поделиться

7 ответов

You should be using scp ("secure copy") rather than ssh ("secure shell").

14
ответ дан 18 December 2019 в 05:21
поделиться

You should use ssh in this way to execute scripts on remote machines,

ssh user@server exec /path/to/script/script.sh

where script.sh is available on the server on the given path from the user login.


If the script is not present on the server but available on your local machine (and you do not have common NFS shared space between the two machines), you should send the script with scp like this,

scp script.sh user@server:/path/to/script/

Now, for your specific case of getting a server file you should just execute,

scp user@server:/path/to/file/filename .

like some other answers already suggest.

3
ответ дан 18 December 2019 в 05:21
поделиться

Кроме того, если вы не хотите, чтобы сценарий был доступен на удаленном сервере, попробуйте следующее:

ssh thehost 'cd /tmp; ls; echo Hello world, I am `hostname`'

и для копирования без SCP:

ssh localhost 'cat /bin/bash' > local_bash
13
ответ дан 18 December 2019 в 05:21
поделиться

ssh in a script doesn't work like that. However it does have the capability to execute a command on a remote server by specifying the command as an argument to ssh, like:

ssh brjones@server.com do_foo.sh

will run the do_foo.sh script on the server

However for your situation it looks like what you are really looking for is SCP.

2
ответ дан 18 December 2019 в 05:21
поделиться

Why not use scp?

0
ответ дан 18 December 2019 в 05:21
поделиться

Several people have already explained how to do the particular example you give better and easier.

If you really do need to script a remote interaction, you might consider using expect.

0
ответ дан 18 December 2019 в 05:21
поделиться

Если вашей целью является только передача файлов, вам следует использовать scp. Но для выполнения некоторых команд на удаленном хосте без специального сценария на этом удаленном хосте вы можете просто использовать стандартный ввод, например:

!/bin/sh
ssh -o PreferredAuthentications=publickey brjones@server.com << EOT
cd ~/folder
echo "hello" > hello.txt
...
EOT
5
ответ дан 18 December 2019 в 05:21
поделиться
Другие вопросы по тегам:

Похожие вопросы: