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 / 问题 / 12621
In Process
FLamparski
FLamparski
Asked: 2010-11-12 01:18:35 +0800 CST2010-11-12 01:18:35 +0800 CST 2010-11-12 01:18:35 +0800 CST

无法运行 shell 脚本 [重复]

  • 772
这个问题在这里已经有了答案:
如何运行 .sh 脚本? (16 个答案)
8年前关闭。

所以我有这个脚本:

#!/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 中的翻转屏幕。我从上网本的 wiki 页面复制了它,并在顶部添加了 #!/bin/bash。文件名为flipscreen.sh。我怎样才能让它工作?

ubuntu-netbook bash
  • 4 4 个回答
  • 2044 Views

4 个回答

  • Voted
  1. OpenNingia
    2010-11-12T01:25:47+08:002010-11-12T01:25:47+08:00

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

    替代文字

    • 2
  2. karthick87
    2010-11-12T01:28:10+08:002010-11-12T01:28:10+08:00

    首先你需要使你的文件可执行,

    在目录类型中,

    sudo chmod+x flipscreen.sh
    
    sudo bash flipscreen.sh
    
    • 2
  3. theTuxRacer
    2010-11-12T01:29:21+08:002010-11-12T01:29:21+08:00

    OpenNingia 的答案会起作用,但对于那些稍后会来谷歌搜索的人,你也可以通过命令行来做:

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

    chmod +x <yourScript>
    

    然后将其执行为

    ./<yourScript>
    
    • 2
  4. tinhed
    2010-11-12T04:09:24+08:002010-11-12T04:09:24+08:00

    双击文件。一个对话框会询问您所说的文件是可执行的,您想做什么。单击“运行”,您应该一切顺利。

    • 0

相关问题

  • 如何设置与 Eee PC 1005 的无线连接?[关闭]

  • 如何在 Ubuntu 上网本版中自定义 gnome 面板?

  • 备份 bash 脚本未压缩其 tarball

  • 上网本版电池寿命 - Ubuntu 与 Kubuntu?

  • 与 Ubuntu 配合使用的多点触控上网本/平板电脑有哪些?[关闭]

Sidebar

Stats

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

    如何安装 .run 文件?

    • 7 个回答
  • Marko Smith

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

    • 24 个回答
  • Marko Smith

    如何获得 CPU 温度?

    • 21 个回答
  • Marko Smith

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

    • 25 个回答
  • Marko Smith

    如何使用命令行将用户添加为新的 sudoer?

    • 7 个回答
  • Marko Smith

    更改文件夹权限和所有权

    • 9 个回答
  • Marko Smith

    你如何重新启动Apache?

    • 13 个回答
  • Marko Smith

    如何卸载软件?

    • 11 个回答
  • Marko Smith

    如何删除 PPA?

    • 26 个回答
  • Martin Hope
    NES 如何启用或禁用服务? 2010-12-30 13:03:32 +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
    Olivier Lalonde 如何在结束 ssh 会话后保持进程运行? 2010-10-22 04:09:13 +0800 CST
  • Martin Hope
    David B 如何使用命令行将用户添加为新的 sudoer? 2010-10-16 04:02:45 +0800 CST
  • Martin Hope
    Hans 如何删除旧内核版本以清理启动菜单? 2010-08-21 19:37:01 +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