AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1007024
Accepted
Thufir
Thufir
Asked: 2018-02-18 02:15:39 +0800 CST2018-02-18 02:15:39 +0800 CST 2018-02-18 02:15:39 +0800 CST

执行一个powershell脚本(hello world)

  • 772

一个powershell“hello world”脚本正在生成并使系统陷入困境:

Tasks: 413 total,   2 running, 411 sleeping,   0 stopped,   0 zombie
%Cpu(s): 42.8 us,  5.9 sy,  0.0 ni, 51.2 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8126688 total,  1785632 free,  4862820 used,  1478236 buff/cache
KiB Swap:  8343036 total,  8343036 free,        0 used.  2875400 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
11915 thufir    20   0 3199524  76936  54220 S  19.2  0.9   0:00.58 b.sh        
11858 thufir    20   0 3068456  76988  54276 S  18.9  0.9   0:00.57 b.sh        
11820 thufir    20   0 3199516  77008  54292 S  18.5  0.9   0:00.56 b.sh        
11877 thufir    20   0 3330588  76796  54040 S  18.2  0.9   0:00.55 b.sh        
11896 thufir    20   0 3199532  76984  54232 S  18.2  0.9   0:00.55 b.sh        
11839 thufir    20   0 3199524  76808  54036 S  17.9  0.9   0:00.54 b.sh        
11934 thufir    20   0 3199520  77152  54360 S  17.9  0.9   0:00.54 b.sh        
10265 thufir    20   0 3609528 167556  83332 S   6.3  2.1   0:06.27 gnome-shell 
10002 thufir    20   0 3447780  86904  61024 S   4.6  1.1   0:00.72 b.sh        
 9965 thufir    20   0 3447764  86904  61036 S   4.3  1.1   0:00.69 b.sh        
 9982 thufir    20   0 3316688  86380  60528 S   4.3  1.1   0:00.71 b.sh        
10021 thufir    20   0 3447760  86548  60628 S   4.3  1.1   0:00.70 b.sh        
10040 thufir    20   0 3316696  86316  60524 S   4.0  1.1   0:00.71 b.sh        
10060 thufir    20   0 3316692  86680  60860 S   4.0  1.1   0:00.68 b.sh        
10080 thufir    20   0 3447768  85824  60020 S   3.3  1.1   0:00.66 b.sh        
 9948 thufir    20   0 3447768  86788  60792 S   3.0  1.1   0:00.66 b.sh        
11799 thufir    20   0 3068444  77012  54192 S   1.7  0.9   0:00.56 b.sh        

剧本:

thufir@dur:~$ 
thufir@dur:~$ cat powershell/weather/b.sh 
#!/usr/bin/pwsh -Command


echo "hello world"
"done"


thufir@dur:~$ 

不能让它成为一个可执行的脚本吗?也许这不是正确的第一行?

详细信息powershell:

thufir@dur:~$ 
thufir@dur:~$ pwsh
PowerShell v6.0.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/thufir> 
PS /home/thufir> $PSVersionTable.PSVersion                                                                              

Major  Minor  Patch  PreReleas BuildLabel 
                     eLabel               
-----  -----  -----  --------- ---------- 
6      0      1                           


PS /home/thufir> 
PS /home/thufir> get-host                                                                                               


Name             : ConsoleHost
Version          : 6.0.1
InstanceId       : 38ca179a-1605-49d3-8af2-15985d6c0536
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-CA
CurrentUICulture : en-CA
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace



PS /home/thufir> 
PS /home/thufir> $PSVersionTable                                                                                        

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      6.0.1                                                                                   
PSEdition                      Core                                                                                    
GitCommitId                    v6.0.1                                                                                  
OS                             Linux 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018                     
Platform                       Unix                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 
WSManStackVersion              3.0                                                                                     


PS /home/thufir> 
scripts programming microsoft webserver powershell
  • 1 1 个回答
  • 4363 Views

1 个回答

  • Voted
  1. Best Answer
    Thufir
    2018-02-18T02:20:18+08:002018-02-18T02:20:18+08:00

    哎呀:

    $ 
    $ cat powershell/weather/c.ps1 
    #!/usr/bin/pwsh -Command
    
    
    echo "hello world"
    "done"
    
    
    $ ./powershell/weather/c.ps1 
    hello world
    done
    $
    

    它只需要具有.ps1文件扩展名。微软。

    • 1

相关问题

  • ubuntu-desktop 主要是用哪种语言编写的?

  • 如何在 Ubuntu 上开发 .NET 应用程序?

  • 如何编写 shell 脚本来安装应用程序列表?

  • 谷歌的 Go 语言有任何 PPA 吗?

  • Mac OS X Automator 的替代品?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve