Articles of shell

麻烦安装ZSH

我做了以下几点: yum install zsh 然后 chsh eduar New shell [/bin/bash]: /bin/zsh 当我input: curl -L http://install.ohmyz.sh | sh 我懂了: You already have Oh My Zsh installed. You'll need to remove /home/eduar/.oh-my-zsh if you want to install 它说我已经安装了模块。 然后,我们的最后一步是重新加载我们的资源文件: source ~/.zshrc 在这里我有以下问题: bash: /home/eduar/.oh-my-zsh/oh-my-zsh.sh: line 26: syntax error near unexpected token `(' bash: /home/eduar/.oh-my-zsh/oh-my-zsh.sh: line 26: `for […]

在Powershell-Function中的格式列表不起作用

我想使用PowerShell脚本中的函数内的格式列表有一些很好格式的输出。 但是,当我使用它,它根本不打印任何东西。 在这个线程中 ,作者有同样的问题。 他被告知不要在一个函数中调用fl,而是将结果返回到main并在那里输出。 当然,将结果返回给调用者听起来似乎是一个好主意。 但是,如果函数嵌套+已经有一个返回值呢? 我想为sslstream输出证书信息。 为此,我必须使用自定义callback函数进行validation。 在这个callback函数中,证书链是可用的(并且应该被打印到屏幕上)。 该函数需要返回$ true 简化: function write-CertDetails([System.Security.Cryptography.X509Certificates.X509Certificate]$cert){ #perform some conversions etc… eg: $certprops = new-object psobject $certprops | Add-Member -MemberType NoteProperty -Name "FriendlyName" -Value $Cert.FriendlyName $certprops | Add-Member -MemberType NoteProperty -Name "SubjectName" -Value $Cert.SubjectName $certprops | fl #this does not work! } [System.Net.Security.RemoteCertificateValidationCallback] $CertValCallback = { param($sender, […]

将文件夹从结构复制到新位置

我有一个像下面900个用户的结构 用户1个人personal.pst 我需要将个人文件夹从每个用户文件夹复制到一个新的结构,如下所示 用户1(差异用户名)个人Personal.pst 我有一个用户名的CSV,到目前为止我有这样的: $Folders = Import-Csv "C:\drv\users.csv" $Personal = Get-ChildItem -Path $Folders.OldPath | where {$_.Name -eq "Personal"} | ForEach ($Person in $Personals{ $destination = $Folder.NewPath Copy-Item -Path $Personal -Destination $destination } 任何帮助,将不胜感激。

Python脚本通过Cron运行时崩溃

我有一个python脚本,完全按照预期完成时,以root用户手动运行。 当我把脚本写入cron.daily时,崩溃100%的时间。 该错误是一个超时错误,但这个问题不是直接排除错误。 执行这个工作: $ /etc/cron.daily/myscript 但它通过cron自动运行时崩溃。 问题:根节点shell和环境/etc/cron.daily执行的有什么不同?

从Powershell文件运行命令

我越来越低于错误。 而通过从Powershell文件复制运行命令,这个文件我打开了记事本,比我运行这个命令通过复制和粘贴在PowerShell提示。 请让我知道,如果我通过在PowerShell提示窗口中复制此文件出错。 下面是Powershell文件的截图。 问候,帕拉姆 $Users = Import-Csv -Path "C:\Userlist-sn.csv" foreach ($User in $Users) { $Displayname = $User.Firstname + " " + $User.Lastname $UserFirstname = $User.Firstname $UserLastname = $User.Lastname $OU = "$User.OU" $SAM = $User.SAM $UPN = $User.Firstname + "." + $User.Lastname + "@" + $User.Maildomain $Description = $User.Description $Password = $User.Password New-ADUser -Name "$Displayname" […]

如果使用shell脚本失败,则重新启动ffmpeg进程streamrtmpvideo

我们使用ffmpeg来实时转发stream。 通常由于未知原因或者由于stream临时停止,命令停止在后台运行。 什么是监视和继续在无限循环中重试ffmpeg命令的最佳方法。 这是目前的命令: avconv -i rtmp://example.com:1935/rtplive/Live2 -pix_fmt yuv420p -s hd720 -vcodec libx264 -preset ultrafast -r 30 -bufsize 600k -acodec libmp3lame -ac 2 -b:a 128k -ar 44100 -f flv "rtmp://example.com/live/adfaf" > avconv.log 2>&1 &

如果超过需要跳过脚本的3次尝试在服务器中重新启动崩溃进程的简单方法?

我有一个文件名hello.sh。 我从crontab每30分钟运行一次这个文件。 在hello.sh中,我有用于检查服务是否正在运行的脚本。 如果它没有运行,那么它将发送一个邮件并重新启动服务。 hello.sh脚本: b=$JAVA_HOME/bin/jps| grep "Bootstrap" | awk '{print $2}' if [ "$b" = "LISTEN" ]; then echo "Bootstrap is running" elif [ "$b" == "" ]; then mail -s "Message from 33 Server, The service is not running its going to restart the server " [email protected] sudo catalina.sh run 它运行完美。 现在,我每30分钟一次运行这个程序。 如果服务没有运行,那么它将尝试重新启动服务。 […]

用cgi shell脚本重启apache实例

我试图从我的浏览器在服务器上重新启动我的apache实例。 为此,我正在使用cgi的shell脚本。 以下是我的代码片段。 echo '<FORM METHOD="GET" ACTION="">' echo '<select name=Website>' for file in $(find /etc/apache/* -maxdepth 0 -type d | cut -c1-23 –complement) do echo "<option value=$file>$file</option> " done echo '</select>' echo "<br><br>" echo '<INPUT TYPE="submit" VALUE="Stop">' echo '</FORM>' website_name=`echo "$QUERY_STRING" | sed "s|Website=||"` cd /etc/apache if [ -d "$site" ] then sudo /etc/init.d/apache stop […]

监视磁盘占用情况

问题应该很简单,但对我来说不是那么明显。 我有一个在MacOS X下的指定目录中创build临时对象的过程。 我需要find进程的磁盘占用率 ,如果可能的话使用shell脚本。 我的问题是,我无法从du -ahcfind一个简单的方法来获取进程运行时的目录大小,并对其进行监视。 即使只是获得最大尺寸,而不是随着时间的推移,我也会解决。 任何人都可以指向正确的方向吗? 谢谢!

powershell导出本地存储证书到pfx没有密码input密码

使用certutil非常简单: certutil -exportpfx -p "" my serialnr path\to\hostname.pfx noroot 我需要将它从pfx转换为pem,所以我需要做一些脚本。 这是我迄今为止: $output = ( certutil -store my | findstr /i seri ) $separator = ":" $serialstring = $output.split( $separator ) $serialnr = $serialstring[1] $exportpfx = "certutil -exportpfx -p `"`" my" + $serialnr + " path\to\"+$env:computername+".pfx noroot" invoke-expression $exportpfx 这几乎工作,但由此产生的pfx文件有一个密码。 所以显然我的$ exportpfx var正在保存更多的信息比它应该,但我看不到什么。 有小费吗? 谢谢!