我一直在嘗試以正確的格式獲得輸出,但毫無結果。我正在運行 putty ssh 命令,命令的輸出被保存到檔案中並傳輸過來。
忽略它是哪個命令這一事實,因為當我在 Putty 會話中的伺服器中手動運行相同的命令時,輸出或將輸出重定向到檔案會將其設定為正確的格式。
命令:
output=$(drush @website.dev --uri=xyz1.com fl)
echo "$output" > xyz1.txt
output=$(drush @website.dev --uri=xyz2.com fl)
echo "$output" > xyz2.txt
output=$(drush @website.dev --uri=xyz3.com fl)
echo "$output" > xyz3.txt
output=$(drush @website.dev --uri=xyz4.com fl)
echo "$output" > xyz4.txt
output=$(drush @website.dev --uri=xyz5.com fl)
echo "$output" > xyz5.txt
如果我運行命令行,我得到的格式:
National Blog national_blog Enabled 7.x-3.32 N
e
e
d
s
r
e
v
i
e
w
OpenLayers Test Example openlayers_test_example_fea Disabled 7.x-2.0-
Feature ture beta9
Owl Carousel Settings owl_carousel_feature Enabled 7.x-1.0
Password Policy Feature password_policy_feature Disabled
Promo Block promo_block Disabled 7.x-1.01
Promo Block i18n promo_block_i18n Enabled 7.x-1.02
RH Accolade rh_accolade Disabled 7.x-1.10
RH Accolade Feature rh_accolade_feature Disabled 7.x-1.0
RH Accolade Translatable rh_accolade_translatable Enabled 7.x-1.04
RH Accolades i18n View rh_accolades_i18n_view Enabled 7.x-0.02
RH Accolades View rh_accolades_view Disabled 7.x-1.0
RH Banner View rh_banner_view Enabled 7.x-0.21
Article Content Type rh_basic_page_feature Disabled 7.x-2.07
RH Blog rh_blog Enabled 7.x-2.20 O
v
e
r
r
i
d
d
e
n
我想要取得的格式以及在 Putty 會話視窗中手動執行此命令時得到的內容:
RH Job Search rh_job_search_feature Enabled Overridden
RH Media Feature rh_media_feature Enabled 7.x-1.13 Overridden
Media Page rh_media_page_feature Disabled
RH Metro Image Styles rh_metro_image_styles Enabled 7.x-1.00
RH Notifications Feature rh_notifications_feature Disabled 7.x-1.00
Office Location Content Type rh_office_location_feature Enabled
Office Locator rh_office_locator_feature Enabled 7.x-1.5
Office Locator v2 rh_office_locator_v2_feature Disabled 7.x-1.0
RH Press Release i18n Content Type rh_press_release_i18n_content_type Enabled 7.x-1.00
RH Promo CT rh_promo_content_type Enabled 7.x-1.21
RH Promo Feature rh_promo_feature Enabled 7.x-1.10
RH Promo i18n Feature rh_promo_i18n_feature Disabled 7.x-1.01
RH Promo Translatable CT rh_promo_translatable Disabled 7.x-1.05
RH Promo Views rh_promo_views Enabled 7.x-1.01
RH Promo Views i18n rh_promo_views_i18n Disabled 7.x-1.00
RH Quicktabs Feature rh_quicktabs_feature Enabled 7.x-0.03 Overridden
PS:我什至嘗試過加載膩子會話,因此打開的膩子視窗大小不會限制並切斷文字:
putty.exe -load "server session xyz" -m "D:\Projects\Drupal\scripts\daily_feature_lists\commands.txt"
還嘗試更改幾乎每個膩子屬性,包括關閉自動換行,似乎對我發送的實際遠端命令沒有任何影響,僅對它打開的終端視窗應用膩子配置。
答案1
COLUMNS
您是否嘗試在執行 drush 之前明確設定變數?
例如:
output=$(COLUMNS=120 drush @website.dev --uri=xyz1.com fl)
echo "$output" > xyz1.txt