无法运行shell脚本

所以我有这个脚本:

#!/bin/bash # Flips the screen (hopefully) syntax_error=0 orientation=0 current_orientation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')" case $current_orientation in normal) current_orientation=0 ;; left) current_orientation=1 ;; inverted) current_orientation=2 ;; right) current_orientation=3 ;; esac if [ $current_orientation -eq 0 ]; then orientation=2 fi if [ $current_orientation -eq 2 ]; then orientation=0 fi method=evdev # LENOVO S10-3t CHANGE ==> Hard Coded my device number to 11!!!!!!!! device=11 swap=0 invert_x=0 invert_y=0 real_topx=0 real_topy=0 real_bottomx=4020 real_bottomy=4020 case $orientation in 0) swap=0 invert_x=0 invert_y=0 topx=$real_topx topy=$real_topy bottomx=$real_bottomx bottomy=$real_bottomy ;; 1) swap=1 invert_x=1 invert_y=0 topx=$real_topx topy=$real_topy bottomx=$real_bottomy bottomy=$real_bottomx ;; 2 ) swap=0 invert_x=1 invert_y=1 topx=$real_topx topy=$real_topy bottomx=$real_bottomx bottomy=$real_bottomy ;; 3 ) swap=1 invert_x=0 invert_y=1 topx=$real_topx topy=$real_topy bottomx=$real_bottomy bottomy=$real_bottomx ;; esac if [ $method = "evdev" ]; then xinput set-prop "$device" "Evdev Axes Swap" $swap xinput set-prop "$device" "Evdev Axes Swap" $swap xinput set-prop "$device" "Evdev Axis Inversion" $invert_x $invert_y xinput set-prop "$device" "Evdev Axis Calibration" $topx $bottomx $topy $bottomy if [ $orientation = 2 ]; then xrandr -o inverted fi if [ $orientation = 0 ]; then xrandr -o normal fi fi # 

这是为了在联想S10-3t中翻转屏幕。 我从上网本的维基页面复制了它,并在顶部添加了#!/ bin / bash。 文件名是flipscreen.sh。 我怎样才能使它工作?

右键单击该文件,然后选择“属性”。 从对话框中选中“允许将文件作为程序执行”,如下图所示。 然后关闭对话框并双击要执行的文件。

替代文字

首先,您需要使文件可执行,

在目录类型中,

 sudo chmod+x flipscreen.sh sudo bash flipscreen.sh 

OpenNingia的答案是有效的,但是对于那些稍后来谷歌搜索的人,你也可以通过命令行:

打开终端,然后转到脚本所在的文件夹

 chmod +x  

然后执行它

 ./ 

双击该文件。 对话框将询问您所述文件是否可执行您想要执行的操作。 点击“运行”,你应该很高兴。