相当于“alias mount=”mount -t ext3”的 shell 脚本?

发布于 2024-11-17 01:57:32 字数 398 浏览 3 评论 0原文

某些第 3 方应用程序执行“mount”,我希望它的意思是“mount -t ext3”,

我知道,通常这可以通过别名来完成。 但这种情况相当罕见,我需要别名以外的东西。

(它与云计算机在另一台计算机上执行远程命令有关。不知何故别名不起作用)

我将把 /bin/mount 重命名为 /bin/mount_execute 并在 /bin/mount 创建一个脚本。
当执行“mount a b”时,我希望将其翻译为“mount -t ext3 a b”

“mount a b”-> '/bin/mount a b' -> '/bin/mount a b' -> '/bin/mount_execute -t​​ ext3 a b'
(其中 /bin/mount 是我要求的脚本)

Some 3rd party application executes "mount" and I want it to mean "mount -t ext3"

I know, normally this can be done by alias.
But this is rather rare situation where I need something other than alias.

(it's related to cloud machine executes remote command on another machine.. somehow alias doesn't work)

I'm going to rename /bin/mount to /bin/mount_execute and create a script at /bin/mount.
when 'mount a b' is executed i'd like it to be translated to 'mount -t ext3 a b'

'mount a b' -> '/bin/mount a b' -> '/bin/mount_execute -t ext3 a b'
(where /bin/mount is the script that I am asking for)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-11-24 01:57:32

alias不起作用时,您可以更改该程序的PATH,以便您的挂载脚本首先出现;这样,你就不必弄乱 /bin/mount (我认为有点危险)

When alias doesn't work, you could change the PATH for said program, so that your mount script comes first; this way, you don't have to mess with /bin/mount (IMO a bit dangerous)

缪败 2024-11-24 01:57:32
#!/bin/bash

mount_execute -t ext3 $@ 

是我需要的脚本。
感谢您的建议。

#!/bin/bash

mount_execute -t ext3 $@ 

was the script I needed.
Thanks for suggestions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文