EvilZone

Programming and Scripting => Scripting Languages => : lucid July 19, 2013, 04:04:18 AM

: [BASH] What?
: lucid July 19, 2013, 04:04:18 AM
I have this script:

:
#!/bin/sh

## Erase contents of all files in /var/log
find /var/log -type f -exec sh -c '> "{}"' \;

## Erase contents of bash history and shutdown
cat /dev/null > .bash_history
shutdown -h now

It used to work, but now everytime I run it it gives me this:

Shutdown scheduled for Thu 2013-07-18 21:03:08 UTC, use 'shutdown -c' to cancel.

Which isn't really that big of a deal as that's only one minute away, but it never used to do that. Not only that, if I run shutdown -h now on it's own in the terminal it shuts down immediately. Why would it behave differently in the script than on it's own in the command line?
: Re: [BASH] What?
: Nerotic7 July 19, 2013, 04:47:28 AM
Er, reinstall bash


: Re: [BASH] What?
: Deque July 19, 2013, 08:47:23 AM
Why don't you use poweroff instead?
: Re: [BASH] What?
: techb July 19, 2013, 09:11:12 AM
Why don't you use poweroff instead?

Arch.

Laptop or desktop?
: Re: [BASH] What?
: proxx July 19, 2013, 09:15:11 AM
I have this script:

:
#!/bin/sh

## Erase contents of all files in /var/log
find /var/log -type f -exec sh -c '> "{}"' \;

## Erase contents of bash history and shutdown
cat /dev/null > .bash_history
shutdown -h now

It used to work, but now everytime I run it it gives me this:

Shutdown scheduled for Thu 2013-07-18 21:03:08 UTC, use 'shutdown -c' to cancel.

Which isn't really that big of a deal as that's only one minute away, but it never used to do that. Not only that, if I run shutdown -h now on it's own in the terminal it shuts down immediately. Why would it behave differently in the script than on it's own in the command line?

Thats because I know you run arch.
These things are handled but systemd nowadays.
Use ; systemctl poweroff
Just throw something in your .bashrc to alias it.
: Re: [BASH] What?
: lucid July 19, 2013, 06:13:14 PM
Arch.

Laptop or desktop?

Laptop

Thats because I know you run arch.
These things are handled but systemd nowadays.
Use ; systemctl poweroff
Just throw something in your .bashrc to alias it.


Oh yeahhhhh. Totally forgot about that *facepalm*

Well, shutdown -h now used to work up until recently. Must have finally become depreciated.
: Re: [BASH] What?
: Snayler July 19, 2013, 06:58:19 PM
Must have finally become depreciated.
  *deprecated
(http://images.wikia.com/powerlisting/images/8/8f/Grammar_Nazi_Icon_Text.svg)
: Re: [BASH] What?
: lucid July 19, 2013, 07:45:40 PM
Oh really?

Depreciated: to lower in estimation or esteem (Webster's)

Deprecated: Computer Science  To mark (a component of a software standard) as obsolete to warn against its use in the future so that it may be phased out. (Free Online Dictionary)

Seems you are right. Lol I've been pronouncing it as depreciated this whole time in my head.

EDIT: What the fuck!! proxx your advice didn't work like I thought it would. I changed it to systemctl poweroff and it still gives me the same output.
: Re: [BASH] What?
: proxx July 19, 2013, 10:19:40 PM
Oh really?

Depreciated: to lower in estimation or esteem (Webster's)

Deprecated: Computer Science  To mark (a component of a software standard) as obsolete to warn against its use in the future so that it may be phased out. (Free Online Dictionary)

Seems you are right. Lol I've been pronouncing it as depreciated this whole time in my head.

EDIT: What the fuck!! proxx your advice didn't work like I thought it would. I changed it to systemctl poweroff and it still gives me the same output.

systemctl reboot
systemctl poweroff
System Commands:
  default                         Enter system default mode
  rescue                          Enter system rescue mode
  emergency                       Enter system emergency mode
  halt                            Shut down and halt the system
  poweroff                        Shut down and power-off the system
  reboot                          Shut down and reboot the system
  kexec                           Shut down and reboot the system with kexec

That doesnt work ?

You sure you have the permissions ?
: Re: [BASH] What?
: lucid July 20, 2013, 06:34:31 AM
HOLY SHIT GUYS. You are all going to disown me as your EvilMate when I tell you this but it must be done so others can read this and not make the same mistake as I. I was running the alias command 'shutdown'. I just looked at my bashrc. Apparently I renamed it to wipedown some time ago and forgot.

So stupid.
: Re: [BASH] What?
: Xires July 20, 2013, 11:14:08 AM
Adding the full path to the binary you intend to run will usually bypass an alias.
: Re: [BASH] What?
: lucid July 20, 2013, 04:12:25 PM
Adding the full path to the binary you intend to run will usually bypass an alias.

Wait, do you mean adding the full path in bashrc? Sorry I'm a little tired.
: Re: [BASH] What?
: Xires July 20, 2013, 08:03:38 PM
In the script that you want to call shutdown.
: Re: [BASH] What?
: lucid July 20, 2013, 09:48:15 PM
In the script that you want to call shutdown.

Right. I'm slow sometimes.