« first day (3637 days earlier)      last day (1310 days later) » 

8:56 AM
i dont get why this doesnt work
```
while $LINE_CONTENT -ne $(head -1 to_be_installed.txt)
do
LINE_CONTENT=$(tail -$N to_be_installed.txt)
apt-get install $LINE_CONTENT
done

```
 
9:06 AM
@AdamL because the syntax is completely wrong? You might want to look at some basic shell scripting tutorials. You can't use -ne as a command, it is only relevant within a test ([ or [[ or test). Your code is trying to run the contents of $LINE_CONTENT as a command, passing ` -ne $(head -1 to_be_installed.txt)` to it as arguments.
Since $LINE_CONTENT doesn't contain a valid command, you get an error.
And the logic doesn't make much sense anyway, your N will never change so you will be running an infinite loop
Presumably, you wanted something like this:
n=1
line_content=$(tac to_be_installed.txt | head -n $n | tail -n1)

while [ "$line_content" -ne "$(head -n1 to_be_installed.txt)" ]
do
  line_content=$(tac to_be_installed.txt | head -n "$n" | tail -n1)
  apt-get install "$line_content"
  ((n++))
done
 
```
N=0
#!/bin/sh
LAST_LINE=$(head -$1 to_be_installed.txt)
LINE_CONTENT=$NULL
while [ "LINE_CONTENT" != "$LAST_LINE" ]
do
N=$(N+1)
LINE_CONTENT=$(tail -$N to_be_installed.txt)
apt-get install $LINE_CONTENT
done
```
ok yeah sorry just woke up probably need to eat breakfast dinner
 
9:22 AM
@AdamL Code-fence formatting doesn't work in chat. You need to paste your code without the backticks and use the "fixed font" button that appears on the right of the composing box.
 
ok thank you
 
@terdon Won't it complain because -ne expects integer operands?
 
@terdon I get an error line 6: [: zlib1g: integer expression expected
ah ok
 
@AdamL Yeah, see my previous comment. String inequality requires !=.
@AdamL Also, the shebang line (#!/bin/sh) needs to be the first one of the file.
 
@fra-san lol, of course it will, but just not if you're an idiot and use seq 10 > file as a file to test it on :)
Like I did.
here you go:
n=1
line_content=$(tac to_be_installed.txt | head -n $n | tail -n1)

while [ "$line_content" != "$(head -n1 to_be_installed.txt)" ]
do
  line_content=$(tac to_be_installed.txt | head -n "$n" | tail -n1)
  echo apt-get install "$line_content"
  ((n++))
done
 
9:32 AM
I need one of those drinking duck things to press the Y button for me now like in the Simpsons when they let him work from home\
 
@AdamL Search the manual of your commands for -y or yes. They often have a built-in "always-say-yes" duck.
@AdamL And in general: N=$(N+1) should be N=$((N+1)) -- see "command substitution" VS "arithmetic expansion"; double-quote your expansions (e.g. apt-get install "$LINE_CONTENT") unless you know you need word splitting and filename generation. shellcheck.net may help you spot issues in your scripts.
 
ok thanks
 
10:02 AM
Also, avoid using CAPITALS for variable names, that's bad practice since env vars are in allcaps and if you do the same for your vars, you can have variable collision.
And yes, apt-get has a -y option:
-y, --yes, --assume-yes
Automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package or removing an essential package, occurs then apt-get will abort.
 
@terdon Testing code is much harder than writing it, I suspect :-)
 
 
2 hours later…
12:10 PM
In Z-shell does sudo have a different environment to the normal user?
When I execute export RESTIC_REPOSITORY=/User/username/repo as a normal user, then try to back up using restic backup / the program restic fails with the message Fatal: Please specify repository location (-r)
Well I just specified the repository location using an environment variable, instead of the -r option. So why is there an error?
 
See the "Command Environment"; there are env_reset and env_keep options that influence the behavior
doesn't matter what shell you're using
 
I meant when I try to backup using sudo restic backup / the program restic fails with the message Fatal: Please specify repository location (-r).
 
sudo RESTIC_REPOSITORY=/User/username/repo restic backup is one potential solution
 
@JeffSchaller Thanks, I see this is the cause of the issue:
> By default, the env_reset option is enabled
> By default, the env_reset option is enabled. This causes commands to be executed with a minimal environment containing the TERM, PATH, HOME, MAIL, SHELL, LOGNAME, USER, USERNAME and SUDO_ variables in addition to variables from the invoking process permitted by the env_check and env_keep options. This is effectively a whitelist for environment variables.
@JeffSchaller So that doesn't export the environment variable, instead it uses it in-line in that command line?
@JeffSchaller I also want to use the environment variable RESTIC_PASSWORD
And I want to prevent that password from being saved to the zshell history file. I know I can use setopt HIST_IGNORE_SPACE for a normal user but how do I get this command to work for sudo?
sudo setopt HIST_IGNORE_SPACE fails with the message:
 
12:25 PM
@BlackPanther it "exports" it to that one command; another option would be to add those RESTIC variables to the sudo configuration with env_keep += RESTIC_REPOSITORY
 
sudo: setopt: command not found
 
env_keep+="RESTIC_REPOSITORY RESTIC_PASSWORD" might do it
 
@JeffSchaller So this tells sudo to keep (inherit) the variable RESTIC_REPOSITORY from the user's environment?
 
@BlackPanther correct
 
I'll try this now, but I would have thought you would need to add the two variables separately, like so?
`env_keep+=RESTIC_REPOSITORY`
`env_keep+=RESTIC_PASSWORD`
 
12:30 PM
@BlackPanther I haven't tested it, sorry; I was basing it off unix.stackexchange.com/q/132748/117549
 
@JeffSchaller Okay, and is env_keep+=RESTIC_REPOSITORY meant to be added to .zshrc` or is it meant to be executed on the command line?
 
@BlackPanther with visudo to edit the sudoers configuration
 
@JeffSchaller Amazing. Thanks, it worked on the first try.
@JeffSchaller do you have any experience wiping a Macbook Pro SSD hard drive?
 
@BlackPanther setopt is a builtin command, it can't be seen by sudo (which is a utility on its own). You can use it if you invoke the shell itself using sudo, e.g. sudo zsh -c 'setopt ...'.
 
I've wiped a linux hard drive before using dd but not sure if the same way is good for an SSD that has MacOS installed on it.
@fra-san Thanks a lot. So next time I can use sudo zsh -c 'setopt HIST_IGNORE_SPACE to stop a command from being written to the Z shell history file.
My first time running restic backup on MacOS, and despite using sudo, I am getting so many operation not permitted errors.
The backup has an ETA of over 3 hours. Is there any way to move a process to the background once it has already started?
 
12:51 PM
@BlackPanther Ctrl+Z and then bg
 
it will still print to stdout though
 
@StephenKitt Thanks. Just to confirm this works on a MacOS running zshell right? And where will the output go?
@AndrasDeak That's what I want.
 
@BlackPanther AFAIK yes. The output goes to the same terminal, which isn’t great (it gets mixed in with the rest of what you’re doing in the terminal)...
 
@BlackPanther:
115
A: If you ^Z from a process, it gets "stopped". How do you switch back in?

terdonThe easiest way is to run fg to bring it to the foreground: $ help fg fg: fg [job_spec] Move job to the foreground. Place the job identified by JOB_SPEC in the foreground, making it the current job. If JOB_SPEC is not present, the shell's notion of the current job is used. ...

 
@StephenKitt I'm using a terminal that has several tabs, one of them running restic backup. Any idea which tab the output of the background process will be sent to?
 
1:00 PM
@BlackPanther The one where you started it.
 
@fra-san Thanks
@terdon Thanks. So Ctrl + z then bg then if for any reason I want to bring it back to the fore ground, then Ctrl + z then fg, right?
 
@BlackPanther just fg
 
@StephenKitt I want to confirm something. A background process continues running even if the lid of the laptop is closed? The only way it stops running is if the background process completes or you shutdown the laptop, right?
@StephenKitt Ok, thanks.
 
@BlackPanther that depends on what the laptop does when the lid is closed; if it suspends then nothing runs
 
@StephenKitt Aah I see, but if it sleeps then any background process continues running?
Yup, restic is showing several errors. I'm gonna have to make a contingency backup using Time Machine.
 
1:13 PM
@BlackPanther what is "sleep"?
if you close your laptop and its power light starts to blink and uses very little power: that's suspend
it wouldn't be much of a suspend if stuff still kept running
 
1:29 PM
@BlackPanther what Stephen said: just fg
As far as I know, the default mac setup is to suspend/sleep (the two mean the same thing) when the lid is closed. If the machine is suspended, that means nothing continues to run.
However, when you open the lid and wake the machine up again, it picks up where it left off and the job will continue.
 
... but note that network connections tend to get lost when a system is suspended and resumed, including those used by backup programs to archive data on remote hosts.
 
@fra-san use NFS! :-P
 
1:45 PM
Current struggle: creating a windows xp installer USB... :'|
 
@StephenKitt Oh! I've never felt the need, I should probably (re)consider it. Do you use it in combination with a backup application?
 
@fra-san I use NFS to access my NAS, but not for backups (I ensure that my backups aren’t mountable, so that disasters on any local system can’t affect them).
 
heh! My first sysadmin disaster was an unexpected NFS mount
 
Did it involve rm -rf?
 
2:01 PM
It did (perl unlink, but same idea)
"Why is this cleanup script taking so long?"
 
rm --one-file-system should be the default
 
after that, I added -n flags to any destructive scripts
(dry-run, show me what you'd do)
 
2:30 PM
Ugh, can't get a freedos livecd to boot either :(
 
3:05 PM
@AndrasDeak When the screen turns off but the laptop is still on in a low power state, at least this is what I think sleep means where devices like laptops are concerned.
@AndrasDeak I understand, the MacBook doesn't make it easy though since Apple's obsession with minimalism means that there is no power light.
@terdon Nice explanation. I think this is why the backup by restic is taking twice as long.
I'm getting unexpected behavior when I run the progam caffeinate from the command line.
` man caffeinate` says:
> NAME
caffeinate -- prevent the system from sleeping on behalf of a utility
 
Do you actually want to close the laptop lid and let the OS keep running?
 
However the system still goes to sleep even after running caffeinate on the command line
 
There's a gnome extension called caffeine. All it does is prevent suspend when the computer is left alone open. Closing the lid is a strong hardware signal. You could probably disable it in the power settings.
 
@BlackPanther low power, yes, but with the CPU stopped; the power used is the minimum required to keep the RAM refreshed.
 
@AndrasDeak I would if I need to bounce. But for now I just want to be able to leave the laptop lid open without the laptop going to sleep.
 
3:12 PM
Trying to run a laptop with the lid closed can lead to thermal problems...
 
@BlackPanther OK, that's sane then. As Stephen said closing the lid while awake would be a bad idea.
you can probably disable the screensaver or auto-suspend in the system settings manually
But yeah, caffeinate sounds like something that would help here. I'm not familiar with macs, though.
 
@AndrasDeak That's what I expected caffeinate on MacOS to do. I leave the lid open yet it still goes to sleep.
@StephenKitt I see, but I think I would risk it with a MacBook, they stay quite cool despite me having several hundred tabs open, and many apps.
 
"we can remove these wings from our airplane; it's been reliably staying in the air" ;)
 
@BlackPanther oh I don’t think there’s much risk of damage, at least in the short term; components throttle themselves nowadays when they overheat. But I do know that many laptops’ thermal design relies on the screen being open to provide adequate cooling through the keyboard.
 
@AndrasDeak That was the first option, but that's no fun :). Mac seems to push you away from the command line. I will have to give in.
 
3:17 PM
@BlackPanther I never said command line
 
A closed laptop has half the surface exposed to air compared to an open laptop...
 
it would be around three clicks in a gnome GUI
(as much as I hate GUIs)
 
I've verified my npmjs account like 7 times now and it keeps asking me to verify it =(
 
@StephenKitt The cold climate here should help it stay cool.
@AndrasDeak Same, my command line/terminal skills have stagnated since I started using a Mac, who knew. Stay away from GUIs
 
@BlackPanther hope you're joking
 
3:24 PM
@AndrasDeak Or I could find a really long youtube video and play it. Probably a 10 hour cat video, shouldn't be hard to find.
@AndrasDeak Well Antarctica is very very cold.
 
@BlackPanther opening a pdf in presentation mode would probably work too
 
@BlackPanther right, you probably have more issues getting hardware up to operating temps than keeping it cool ;-)
 
@AndrasDeak Yup, there is more than one way to skin a cat.
There's probably a video for that too.
I'm joking btw. Before you send PETA after me
@StephenKitt haha, tell me about it. At least you don't need a fridge.
 
3:57 PM
@BlackPanther You should be able to change that in the settings somewhere. It's a pretty basic thing.
 
@terdon Yeah, I know. The setting is in energy saver preferences. Wanted to do it via command line.
 
Ah, well then. 10 Geek points to you, my good panther! :P
 
mount: /media/user/tmpdir: WARNING: source write-protected, mounted read-only.
*sigh*
 
 
1 hour later…
5:10 PM
@terdon :)
 

« first day (3637 days earlier)      last day (1310 days later) »