Solved

shutdown

Posted on 2009-04-06
8
410 Views
Last Modified: 2012-05-06
can we write any exe/code in linux that run automatically like (autorun file in windows) which can call shutdown of system.

in other words, linux file that call shutdown as soon as cd having code inserted / try to access by user.
0
Comment
Question by:Indarnav
  • 3
  • 3
  • 2
8 Comments
 
LVL 29

Assisted Solution

by:fosiul01
fosiul01 earned 200 total points
ID: 24076239
to shutdown linux server you can put this code in a shell script

Create a script call shutdown.sh

if you are  running that script as root

just put this line

shutdown -h now

then when you will run that script

./shutdown.sh

it will shutdown automaticaly

if you want to make it automated, you can put this one in Cron tab fiel to make it automated in Certain time ..

0
 

Author Comment

by:Indarnav
ID: 24076299
then it will work as autorun ..??
0
 
LVL 29

Assisted Solution

by:fosiul01
fosiul01 earned 200 total points
ID: 24076326
omm in linux word , autoran mean

you need to run a script in a certain time ..

suppose if you want to shutdown linux server at 5 Pm every day

so create crontab

crontab -e

00 17 * * 1-5 /root/shutdown.sh

then Save crontab file

so that script will run every day at 5 Pm

or you can directly add that command in cron tab

do you want something like this ??
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:Indarnav
ID: 24076415
can i run any exe which can add this to cron tab? and that exe will run as soon as user access cd.
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24076434
omm linux does not support exe format .

what are you tryign to do ??

when user will try to access a Cd rom , system will shutdown ??
0
 
LVL 35

Accepted Solution

by:
torimar earned 300 total points
ID: 24076512
If what you are looking to do is to create a CD that will automatically run a script once inserted, then this is not possible.

There is no Windows like autorun feature in Linux, because that would be a highly insecure feature. On Windows, malware has been distributed this way.

But even if there were such a feature, your project would most likely fail because of a variety of reasons, but mainly because Linux systems tend to differ from each other:

1. In order for autorun to work, CDs must be mounted first. Not all systems are set to automount.

2. In order for autorun to work on a mounted filesystem, this must be expressly defined to allow execution of executable code. This is not the case by default.

3. Linux is a multi-user architecture with a highly intricate permission system. What would be configured to work for one user need not work for another.

4. On a sidenote, your project would even fail to work on any of my Windows systems, because I tend to disable autorun for being an annoying and insecure feature.
0
 
LVL 35

Expert Comment

by:torimar
ID: 24076661
ps:

Some modern Linux distros will automatically play an audio CD or video DVD with the associated player when inserted. But this feature cannot be exploited for your project, because a) it works only for multimedia, not for data CDs/DVDs; b) it has to be configured in the window manager settings - and there are more than half a dozen window managers your possible client could be using.
0
 

Author Comment

by:Indarnav
ID: 24076756
thanks for info.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question