简体   繁体   中英

how to ssh on a server with sed shell command afterwards

I'm trying to shh on a server and execute a sed command afterwards. Sadly I get a weird error.

If i run this command it works

sed -f <(printf "s/${DOMAIN}\.%s/www.&.${FOO}/g\n" ${LANG_KEYS}) ${DB_PATH_TO}${DB_NAME}.sql > ${DB_PATH_TO}new-${DB_NAME}.sql

If i however try to run it with a ssh it does not, i believe it is because of the quotes but i'm unsure of how to fix it.

ssh ${TARGET_USER}@${TARGET_IP} -i ${TARGET_PRIVATE_KEY} -p ${TARGET_PORT} "
    sed -f <(printf "s/${DOMAIN}\.%s/www.&.${FOO}/g\n" ${LANG_KEYS}) ${DB_PATH_TO}${DB_NAME}.sql > ${DB_PATH_TO}new-${DB_NAME}.sql
"

Output:

bash: -c: line 1: unexpected EOF while looking for matching `)'
bash: -c: line 2: syntax error: unexpected end of file 
No such file or directory

Try that:

ssh ${TARGET_USER}@${TARGET_IP} -i ${TARGET_PRIVATE_KEY} -p ${TARGET_PORT} '
    sed -f <(printf "s/${DOMAIN}\.%s/www.&.${FOO}/g\n" ${LANG_KEYS}) ${DB_PATH_TO}${DB_NAME}.sql > ${DB_PATH_TO}new-${DB_NAME}.sql
'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM