PDA

View Full Version : [ubuntu] scripting



joe1600
February 13th, 2010, 04:22 AM
hiii
am new to ubuntu uinix linux etc..
i would like to know how to write scripts for example
sudo apt-get install wireshark..supply the passwd then answer y or no question and then shudown using init 0 ...

expecting help

reagrds

Joe Joseph

Satoru-san
February 13th, 2010, 05:04 AM
Hey Joe, welcome to the forums.

Unfortuantly there is no way to get it to enter your password for you. Besides why would you need to have a program that did that, its a security risk.

pizza-is-good
February 13th, 2010, 05:05 AM
I used this book (http://gd.tuwien.ac.at/linuxcommand.org/tlcl.php) to learn how to use the terminal and scripting. It is very good.

Good luck.

~pizza

jken146
February 13th, 2010, 05:12 AM
Don't shutdown by doing 'init 0'. Use the command
shutdown

Satoru-san
February 13th, 2010, 05:20 AM
Don't shutdown by doing 'init 0'. Use the command
shutdown

sudo halt
If you ever decide to use a different distro there is no shutdown command instead you type halt to turn off your computer.

Vishal Agarwal
February 13th, 2010, 05:30 AM
Don't shutdown by doing 'init 0'. Use the command
shutdown

what is the harm using init 0 ?
i use it many times.

jken146
February 13th, 2010, 05:40 AM
what is the harm using init 0 ?
i use it many times.

I've had a poke at the docs, and it seems that there is in fact no harm at all. shutdown, telinit, reboot and halt are just different tools for changing the runlevel. shutdown does have the advantages of setting times and messages, but there's no difference in the actual shutting down process.

spcwingo
February 13th, 2010, 05:58 AM
Try this, but I'll go ahead and tell you that it will just prompt for password, not enter it for you:


#!/bin/bash
#
gksudo apt-get install -y wireshark && gksudo shutdown

EDIT: Just note the the above command will only work under GTK environments (gksudo). If you are using KDE just replace gksudo with kdesudo.

iponeverything
February 13th, 2010, 02:25 PM
expect can be used to interact with passwd (among many other things)