分页: 1 / 1

新手-自编译的脚本-不知道对不对?

发表于 : 2015-10-01 14:47
九天星
自编译的一个简单脚本,不知道对不对?因是安装软件的,又不能测试,只能在这里请教了!

因是新手,编译的很简单,高手莫笑 :em03

问题:在输入sudo apt-get install指令后,接下来有一个要输入密码的过程,这个过程如何通过脚本将密码加进去而不用在手工输入呢?

代码: 全选

#!/bin/sh
echo "安装嗅探工具"
sudo apt-get install etherape
sudo apt-get install wireshark
echo "安装无线破解工具"
sudo apt-get install aircrack-ng
echo "安装ARP欺骗工具"
sudo apt-get install dsniff
echo "安装LINUX下的VISIO工具"
sudo apt-get install dia
echo "安装扫描工具"
sudo apt-get install nmap
echo "安装文本编辑器"
sudo apt-get install gvim

Re: 新手-自编译的脚本-不知道对不对?

发表于 : 2015-10-01 15:15
温习江湖
把 apt-get 在 /etc/sudoers 的 NOPASSWD里面设置一下
https://www.google.com.hk/url?sa=t&rct= ... 1u74df7hoA

Re: 新手-自编译的脚本-不知道对不对?

发表于 : 2015-10-01 16:55
PithornDawn
echo "密码明文" | sudo -S sh -c "命令"

Re: 新手-自编译的脚本-不知道对不对?

发表于 : 2015-10-01 20:02
九天星
PithornDawn 写了:echo "密码明文" | sudo sh -c 命令

代码: 全选

#!/bin/sh
echo "安装嗅探工具"
echo "密码明文" |sudo sh -c  sudo apt-get install etherape[code]

再次请教,是上面写的这样吗?

Re: 新手-自编译的脚本-不知道对不对?

发表于 : 2015-10-02 12:52
PithornDawn
九天星 写了:
PithornDawn 写了:echo "密码明文" | sudo sh -c 命令

代码: 全选

#!/bin/sh
echo "安装嗅探工具"
echo "密码明文" |sudo sh -c  sudo apt-get install etherape[code]

再次请教,是上面写的这样吗?[/quote]

echo "密码明文" |sudo -S sh -c  "apt-get install etherape"

抱歉上次忘了 -S
[s]因为我早就按2L做了nopasswd了[/s]

密码明文存储不安全。慎用。

Re: 新手-自编译的脚本-不知道对不对?

发表于 : 2015-10-04 9:38
YeLee
密码可以用$1吧。 :Haha