我想寫一個腳本來使用「SSH EXEC」類型構建步驟在teamcity中重新啓動我的服務器。嵌套的bash命令不工作在teamcity ssh exec
腳本必須做的事情之一是解壓縮上一步中我上傳的zip文件,但文件名中的版本總是會更改,所以我試圖使用嵌套查找zip的名稱命令。
unzip `ls | grep zip`
這個工作對我來說,當我ssh到我的服務器和做終端,但是當TeamCity的嘗試做這是行不通的。我在構建日誌中收到以下消息
[19:36:55][Step 3/3] UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.
[19:36:55][Step 3/3]
[19:36:55][Step 3/3] Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
[19:36:55][Step 3/3] Default action is to extract files in list, except those in xlist, to exdir;
[19:36:55][Step 3/3] file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).
[19:36:55][Step 3/3]
[19:36:55][Step 3/3] -p extract files to pipe, no messages -l list files (short format)
[19:36:55][Step 3/3] -f freshen existing files, create none -t test compressed archive data
[19:36:55][Step 3/3] -u update files, create if necessary -z display archive comment only
[19:36:55][Step 3/3] -v list verbosely/show version info -T timestamp archive to latest
[19:36:55][Step 3/3] -x exclude files that follow (in xlist) -d extract files into exdir
[19:36:55][Step 3/3] modifiers:
[19:36:55][Step 3/3] -n never overwrite existing files -q quiet mode (-qq => quieter)
[19:36:55][Step 3/3] -o overwrite files WITHOUT prompting -a auto-convert any text files
[19:36:55][Step 3/3] -j junk paths (do not make directories) -aa treat ALL files as text
[19:36:55][Step 3/3] -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields
[19:36:55][Step 3/3] -C match filenames case-insensitively -L make (some) names lowercase
[19:36:55][Step 3/3] -X restore UID/GID info -V retain VMS version numbers
[19:36:55][Step 3/3] -K keep setuid/setgid/tacky permissions -M pipe through "more" pager
[19:36:55][Step 3/3] -O CHARSET specify a character encoding for DOS, Windows and OS/2 archives
[19:36:55][Step 3/3] -I CHARSET specify a character encoding for UNIX and other archives
[19:36:55][Step 3/3]
[19:36:55][Step 3/3] See "unzip -hh" or unzip.txt for more help. Examples:
[19:36:55][Step 3/3] unzip data1 -x joe => extract all files except joe from zipfile data1.zip
[19:36:55][Step 3/3] unzip -p foo | more => send contents of foo.zip via pipe into program more
[19:36:55][Step 3/3] unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
[19:36:56][Step 3/3] SSH exit-code [0]
爲什麼不只是'unzip * .zip'? – Barmar
我也使用這種嵌套的命令風格來執行其他命令。所以我仍然想知道爲什麼嵌套命令不起作用。謝謝你的信息!我不知道解壓縮可能需要一個正則表達式 –
通配符由shell擴展,它們自動適用於每個命令。 – Barmar