« first day (1860 days earlier)      last day (3401 days later) » 

22:07
@terdon your answer work so well i forgot i was using a virtual-machine :P
@terdon just copy paste outside and inside the virtual box as it is a native program
I don't feel up to editing this: askubuntu.com/questions/693153/…
Anyone want to encourage my laziness?
what is the difference if a ran script in terminal and run as service?
@kos what is the difference if a ran script in terminal and run as service?
@kos @ByteCommander By the way, I've just been thinking of this question here and I've thunk up another idea - padding filenames with something. In other words mv $file $file-TMP, then once all files are padded, actually add +10 to filename and move $file-TMP to new filename. So . . . again that's two loops . . . probably not good with large amounts of files . . . but i kind of have a sense there has to be a way to improve it . . .
@edwardtorvalds as service it runs in background, in terminal it occupies your terminal until done . . .unless you tell it to run in background
22:23
@Serg what does it means 'it runs in background' ?
@edwardtorvalds you don't see it running except in a task manager
@Zacharee1 @Serg besides having run in background, what other feature is provided by services?
@edwardtorvalds what zacharee1 said ^
@edwardtorvalds other features . . . hmm let me think
@Serg I can put a script in start-up, then why there is need for services?
@Zacharee1 i didn't knew there was an alien in linux ( sudo alien -d utserver.tar.gz )
22:27
@edwardtorvalds A service runs in the background waiting to be called. A script usually runs then terminates, and is only used when directly called.
@edwardtorvalds AFAIK what's in /init folder is the services and those are basic programs that should run when you boot up . . .Your script is custom thing, it's not exactly necessary for the basic system to run
That;s why there is need for services. It's like wheels to the car
alien - Convert or install an alien binary package FFS :P
@GeoMint that's very descriptive title . . .(unknown) :D
22:29
chat made it :P i just pasted a link
kos
kos
@Serg By the way using mv the files aren't copied / moved, their entry in the filesystem is changed but that's about it.
@edwardtorvalds Daemon is pretty generic. The idea is that everything which runs "on his own" is a daemon
@Terrance what if the service script does not contain any while loop or something and it does its job one time and dies? 'services runs in background waiting to be called' why can't script wait on hard drive waiting to be run ?
@kos what if the service script does not contain any while loop or something and it does its job one time and dies? 'services runs in background waiting to be called' why can't script wait on hard drive waiting to be run ?
@kos wait wait wait, back up, woah, there ! mv doesn't actually copy the files ? Details please
I just mv'd ( renamed ) a file and inode didn't change . . .so . . .what does that mean ?
@GeoMint Glad to hear it :)
@edwardtorvalds you never answered my comment on your question. I can answer it but I don't know what you need yet. Do you need to check if i) the NIC is up? ii) you are connected to a network or iii) you are connected to the internet?
@terdon ii)
22:34
@edwardtorvalds So you don't care if the internet is accessible, only the LAN?
Just parse ip link
@Zacharee1 askubuntu.com/questions/693153/… did he want a server or a client?
@terdon yup, ok
may be useful
@terdon the thing is I wanted a trigger that will also say if the network has changed every time it happens
@terdon by network change I mean up or down
@Serg how you get a shorten url for question
22:38
@GeoMint Click Share button underneath the question
@edwardtorvalds Well, yiou can get the current status in $status using:
@Serg wow, it was so easy :P
ip link | grep -q 'enp3s5.* UP' && status="UP" || status="DOWN"; echo $status
@GeoMint yeah, it's pretty neat. I use it a lot when i need to reference a question or answer
@terdon you are not getting me, who will notify me immediately if network has changed?
22:41
@edwardtorvalds Your script :) Hang on.
kos
kos
@Serg If the inode doesn't change probably it's because the entry just gets attached to the new "branch" in the filesystem tree. Imagine a binary tree in C, I guess that's roughly the implementation of a filesystem
@terdon hows my script will know that the network has changed without using a loop or something?
@edwardtorvalds Why would you not use a loop?
kos
kos
@edwardtorvalds By the way did you see my answer here? askubuntu.com/questions/693002/… Let me know if it doesn't work for you somehow
@terdon because I hate them :)
22:42
@edwardtorvalds Umm... You're going to have trouble writing useful programs then.
@terdon David Foerster gave me the answer I wanted :) thanks btw
@edwardtorvalds without a loop, you're going to have to set up a cron job to call your script every so often
@Terrance nope
@edwardtorvalds Then how do you propose that you are going to write a script as a service?
kos
kos
@Serg By the way try to mv a big file (say in the GB order) everywhere but to another partition, it gets moved instantly
22:43
@edwardtorvalds Then please post it as an answer.
@terdon yes I will
@Terrance does this helps to clear your doubt? askubuntu.com/questions/692281/…
@edwardtorvalds That does, but that is using the Network Manager service
Ah, I see, so you won't write a service but instead add a script to /etc/NetworkManager/dispatcher.d that responds to the up argument.
@Terrance that means I dont have to use loop :)
@terdon you are smart
(aplogize me for yellling)
PEOPLE NEED TO UNDERSTAND THE FACT THAT USING BASH TO DO STUFF IS NOT ALWAYS GOOD, NOT USING IT SOMETIMES GIVES YOU MORE ELEGANT WAY OF DOING THINGS, USE A TRIGGER, FOR EXAMPLE: LOOK UP NETWORK MANAGER WORKS :)
Note that this will make your approach less portable though. I don't know if that's a problem for you.
@edwardtorvalds Yes, it works by running BASH SCRIPTS!
22:47
@terdon portability is not a problem
@terdon using bash always is bad
@edwardtorvalds You never mentioned that it would be using the Network Manager to begin with.
@edwardtorvalds I'm just pointing out that your approach also uses bash. Or sh anyway.
@Terrance I never said I dont want to use NM, so I never stopped any1 to suggest it to me
@terdon I said 'always'
@kos Just did that with deepin iso . . . so it does move instantly, but . . . what's going on there ? I'll need to research mv a little because up to this point I believed mv actually writes sequence of bytes that comprise a file into a new file
@terdon triggers are better approach
22:49
shrugs
@terdon you script might be less portable but the approach is not dumb as a loop
are we done on this? I have another question to ask...
@Serg @Terrance @kos technically what is the difference between service and a normal script?

1. People say service runs in background and does not occupy a terminal. I can make a script run using `&` or something and thus it will run in background.
2. People say service waits in background waiting to be executed when needed. Why can't I keep a script on hard drive and keep it waiting (which means do nothing to it) and run when needed?
3. People say service runs all the time in background. I can use `while` loop in my script and run it all the time.
@edwardtorvalds None really. The main difference is that a service is launched by the system (init, usually). It can be a script, usually is.
Wow you people talk a lot
22:54
@terdon suppose I make a script and it is running, how do I call it terminal to know the current status of its?
@edwardtorvalds I don't understand.
What status? Whether your script is running? Use ps or top.
@GeoMint nice, but they don't necessarily want to remove alien. I'd take that out
@Zacharee1 he said "how to remove them"
he should be more clear next time :p
@GeoMint Is English your first language though? ;p
no, i am Greek
22:56
@terdon I have made a script, ok? and it is running as a service, ok? now for example, suppose it has a counter, how can I know the value of that counter from terminal?
@GeoMint Don't worry, nobody's perfect.
@edwardtorvalds You can't.
You would need to have your script print the value of the counter somewhere.
@terdon i like it more that i am greek ;)
@terdon so there is no way to know the variables inside it?
@terdon is there anyway to change its behaviour by running it as, for example, service name <some argument> ?
22:58
@edwardtorvalds Not that I know of, no. I don't see how that would be possible. You might be ab;e to do something very convoluted and get certain shell variables if you export them through the /run interface but I doubt it. I think there was a question on U&L about this. Let me check.
@kos whats your views ?
@Zacharee1 i installed alien and utorrent server into my vbox :P lol
kos
kos
@edwardtorvalds Output to a named pipe, AFAIK that's the best way of making two scripts communicate
@GeoMint heh
kos
kos
@edwardtorvalds On what?
22:59
@kos same thing i asked terdon, I have made a script, ok? and it is running as a service, ok? now for example, suppose it has a counter, how can I know the value of that counter from terminal?
@edwardtorvalds For a loop, you could output the variable into a type of log that you could then call at anytime to see where it is at.
cat log
@Terrance ok, but is there anyway to change its behaviour by running it as, for example, service name <some argument> in terminal?
kos
kos
@edwardtorvalds As terdon said you can't
so sad :(
@kos @terdon by pipe you mean like this? ls | grep something ?
@edwardtorvalds well, you cannot change behavior during run-time, but if you could always choose to log its output
BRB guys, need to switch buildings
23:02
changing the behaviour of the running script is what i wanted :(
@edwardtorvalds Yes, that's a pipe. Don't use them with ls though, that's usually a bad idea.
FIFO's are FUN!
@edwardtorvalds What are you trying to do, there's probably another way.
@terdon why is that so?
Variables are internal to the script, they can't be shared.
@edwardtorvalds What, the ls? Read the link.
23:03
@terdon got the variable thing
ps -ef | grep -v grep | grep "scrub -f" > /dev/null
check=$?
while [ $check -eq 0 ]; do
rm -f /tmp/results
for CD in `cat $1.drivelist`; do
DRV=`basename $CD`
tot=`cat $DRV.tmpscrublog | tr -cd ".|" | wc -c`
tot="$(($tot - 1))"
perc="$(($tot / 4))"
echo "Drive $DRV Scrub Complete: $perc%" >> /tmp/results
done
clear
cat /tmp/results
sleep 4
ps -ef | grep -v grep | grep "scrub -f" > /dev/null
check=$?
done
^Is a while loop until the check changes
@terdon I know what is ls, but why not to use pipe with it?
@edwardtorvalds Because it breaks very, very easily. Read the link.
kos
kos
@edwardtorvalds Almost: they look like file (i.e. you can see them in your filesystem and output to them as they were files) but they act as a pipe, and a script / processes can read from them. en.wikipedia.org/wiki/Named_pipe. What are you after exactly?
@kos basically I want to change the behaviour of a running script based on events :(
23:05
@edwardtorvalds You can do that, but you have to do it from the script itself.
(meanwhile if anyone has energy to debate: askubuntu.com/q/693173/294611 )
Probably by using a loop.
@terdon again a loop :(
@edwardtorvalds Yes. You will have to get over your dislike of loops. They are very useful tools.
@terdon so we cant call the running script from terminal right?
23:06
?
kos
kos
@edwardtorvalds Post a question about it, but be precise. "I want to change the behaviour of a running script based on events" is quite broad ;)
@terdon @kos thats enough for today :) thanks :) I got your points :) gotto love loops
0
Q: technically what is the difference between service and a normal script?

edward torvalds People say service runs in background and does not occupy a terminal. I can make a script run using & or something and thus it will run in background. People say service waits in background waiting to be executed when needed. Why can't I keep a script on hard drive and keep it waiting (which mea...

@GeoMint why the kbd around the command?
23:10
why vote down its a logical question
it has nice look :P
i can change that
scripts can be services. Services aren't always scripts.
@edwardtorvalds I didn't downvote but we just asnwered that here. Why are you asking again?
@GeoMint Please use proper code formatting for code :)
23:11
not convinced enough
The difference is in the way they are run more than anything else. You run scripts, the system runs services.
four spaces for independent lines, backticks for inline.
Or ctrl+k on highlighted text
@Seth can you fix it?
23:12
just did :)
ohh ok :D
community work :D i like this site
kos
kos
@edwardtorvalds By the way there's no "technical" difference, it's about how you want to call things. A service run constantly between it's started and stopped, and therefore acts as a daemon. A script may act like that as well (in fact lots of services are actually script). There's no technical difference, the difference is in what you understand from the two terms.
@terdon is this an edit war?
hahahaha
its a golf day :P lol
23:15
@Zacharee1 Hardly! Seth's edit came through while I was working on mine.
ha! lol
And mods don't have edit wars. We have differences of opinion expressed through sequential editing.
5
:P
@terdon okay, so I didn't run the grammar check ;p
@terdon let me bite you with this sentence "A service run constantly between it's started and stopped," what if my service has just one command in it, say, ls. how can this command run always from its start to stop? does this mean it is run every second?
23:16
while true do ls sleep 10 done
@Mateo it contains just one command, ls
but format it and stuff
mine didn't
ctrl+k it @Mateo
@edwardtorvalds So how do you make that into a service? I suggest you read man init.
7 mins ago, by Seth
scripts can be services. Services aren't always scripts.
23:18
ls won't be your service, you will have a service which launches ls. The details will depend on how you set it up.
7 mins ago, by terdon
The difference is in the way they are run more than anything else. You run scripts, the system runs services.
Unless we're talking Windows here...
...in which case "service" means something completely different.
and that is that.
@terdon so simple scripts like below cannot be made a service?

#!/bin/bash
ls
23:18
i am going to sleep. have a good night :) \o
@NathanOsman Yes, in the Windows world they come in packs, right?
@terdon btw I am going to read man init
@terdon No, they are executables run by the service manager.
@edwardtorvalds No. They can be launched via a service.
@GeoMint night!
23:19
Night @GeoMint
kos
kos
Oh man
@GeoMint o/
@terdon can loops be used to make a service?

#!/bin/bash
while []
do
##some stuff to do
done
@edwardtorvalds It's only a service if it is launched by the service manager. If you have that script launched as a service, then it is a service.
23:21
@terdon dont worry I am enabling it by systemd, but why just ls be a script :(
The same exact script launched manually by you is not a service.
@edwardtorvalds I don't understand.
:'(
@terdon let me put it in another way, what makes a script to run all the time? a loop or something else?
The script runs until it completes.
@NathanOsman exactly
A "service" or "daemon" is one that doesn't complete. It uses an event loop to do something.
23:24
^^
@NathanOsman that is what makes me wonder, what keeps a service run in background always
For example, an HTTP daemon waits for new connections and processes them.
Edward has a thing against loops.
@terdon not like that
The Windows Win32 API is one giant loop.
23:25
I don't know of any system to get a program to run endlessly that doesn't involve a loop.
kos
kos
@terdon I think he wants a formal definition of service and script. And @edwardtorvalds I think the closest you can get to a formal definition is: a service is whatever thing is started by systemd and runs constantly (which might be a script); a script is not necessarily a service.
@terdon I wonder what keeps a service run all the time, if script runs until it completes.
while(event = getNextEvent()) {
    processEvent(event);
}
^--- like that
@kos I wonder what keeps a service run all the time, if script runs until it completes.
@edwardtorvalds There's another program whose job is to run the service. That program has a loop.
23:26
here is my own very special demonstration of a fifo:
@terdon you mean there is a program that runs services by putting them in a loop?
@NathanOsman the last example you gave is of deamon?
That's a hypothetical example of how a daemon might work in its most basic sense.
23:28
@edwardtorvalds In some cases, yes. Look at what @NathanOsman showed. the processEvent(event) would be launching a script.
@NathanOsman I can make any script a service right?
could be useful if you want to output the error messages and monitor in realtime
Wait - are we talking about short-running scripts invoked at regular intervals (like cron) or a daemon that runs in the background?
@Mateo cat dog | toilet > sink
@NathanOsman daemons I think.
23:29
@edwardtorvalds "service" is generally considered a synonym for "daemon".
systemd refers to "daemons" as "services".
@NathanOsman but, can I turn any script into a service?
It depends what the script does.
@NathanOsman suppose that service script does one thing and dies, what will happen then?
The concept of making a script into a service doesn't really apply. Either it behaves like a service (and therefore is one) or it doesn't (perhaps computing a value and immediately exiting).
@edwardtorvalds Nothing will happen. It's dead :P
@NathanOsman this.
13 mins ago, by Mateo
7 mins ago, by Seth
scripts can be services. Services aren't always scripts.
23:31
@NathanOsman so you suggest the only way to keep a service alive is a loop ?
@ParanoidPanda yes, or I wouldn't have upvoted! :P
@edwardtorvalds Either a spinloop (very bad idea) or an event loop.
spinloop?
@Seth I get "scripts can be services" and but not "Services aren't always scripts"
while(true) {
    if(somethingToDo()) {
        doStuff();
    }
}
^--- spinloop (and don't ever do that)
@Mateo thank you for teaching me ( indirectly ) new stuff today . . .mkfifo O_O
23:33
@NathanOsman because it might eat a lop of cpu right?
@A.B. Thank you! :-)
@edwardtorvalds It will eat your CPU :)
@terdon you know why I hate loops: Nathan Osman @edwardtorvalds It will eat your CPU :)
@edwardtorvalds Well, if you do it that way, sure!
loops, loops I hate thy guts :)
23:34
@Serg won't be able to forget that one now ;p
@KGIII "Yearling" silver badge!!!
This one won't though:

while(true){
if(somethingToDo()) {
doStuff();
}
else{
sleep 1
}
}
@terdon thats why loops are last choice for me, until then i keep digging
Event loops are okay.
@NathanOsman noted :)
23:35
@edwardtorvalds You misunderstand. There is nothing wrong with loops. What Nathan showed is just a bad loop.
@edwardtorvalds Apache isn't written in bash :)
And I clearly pointed out that it was a bad loop.
@NathanOsman Anything wrong with something like this? while :; do something; wait 1; done?
@Seth in C ?
@terdon Well, it is far less taxing on the CPU since it yields control for a second each time through the loop.
23:36
@edwardtorvalds to put it another way, pick any 10 random programs, you have a 99% chance that all of them will have at least one loop.
But an event loop relies on the operating system to "wake" it when an event comes in for processing.
@A.B. Yeah, well, while you lot were partying for my Yearling badge I was actually helping out a friend with ALS (Lou Gherig's disease to you Americans) with cleaning up a parts list... :P CC @KGIII @ByteCommander
The OS will provide a syscall like "waitForEvent()" that will "hang" until an event comes in.
@Fabby ALS is the name here too
@NathanOsman Which is great if you can use it, if there is an event that can be handled that way, but that's not always the case.
23:37
Everyone's too lazy for the full name
@terdon True. And then you rely on a timer or a loop similar to yours.
@terdon I want to run a service using event loop,and you know that I want to use NM events
@Zacharee1 Ah? When did that change???
Well then happy AU Birthday @Fabby. :D (Still sort of AFK. Got hugely busy today.)
@Fabby idk, but I've just never heard people actually say Lou Gherig's Disease
23:39
@Fabby if ( Fabby its your birthday today? == true )
{ happy birthday :) }
@KGIII it's 6:40PM
@edwardtorvalds Yes, that should be fine. However, note that NM itself will almost certainly be running a loop. You can't really program without loops. They are essential for most thigns.
@KGIII Double thanks then! No need to reply from your phone! 2morrow is another day!
@edwardtorvalds Yeah: One year on Ask Ubuntu-birthday!
Happy birthday Fabby!
@edwardtorvalds {print("Happy Birthday")}?
23:39
Yearling silver badge!
So only to people here it matters...
>:-)
oh, I have one that is even better
fifo's with looping now
I am Member for 1 year, 4 months
The USB port on my Teensy just fell off... -_-
My school Teensy, might I add
oops
23:42
@Mateo fifofifofifofifofifofifofifofifo?
@terdon I dont know, you should look this:

file /usr/sbin/NetworkManager
/usr/sbin/NetworkManager: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=de48f56393766e83c578b41f72de201e2a272e38, stripped
@terdon :D
Wut. The source tarball for GNU Hello is over 700 KB.
@edwardtorvalds Is your collection script working now???
23:43
@edwardtorvalds Yes, I guarantee you there will be some loops in its code.
@Fabby am on it, but the concept of script is disturbing me
@terdon ok maybe
@NathanOsman do you know that NetworkManager can trigger events?
@edwardtorvalds Why?
@Fabby thats why I am eating the brains of people here :)
I haven't worked with NetworkManager, I'm afraid.
@Seth XD
23:44
Because your script is not event-driven??? :D
@Fabby I am confused between a script and service
@Seth watching
@Seth thanks for helping me get over the grief of losing my Teensy :p
@edwardtorvalds A script is interpreted code...
23:45
@Fabby my doubt:



People say service runs in background and does not occupy a terminal. I can make a script run using & or something and thus it will run in background.
People say service waits in background waiting to be executed when needed. Why can't I keep a script on hard drive and keep it waiting (which means do nothing to it) and run when needed?
People say service runs all the time in background. I can use while loop in my script and run it all the time.
People say service starts on boot and runs on its own. What stops me from keeping my script in start-up list.
@edwardtorvalds a Service SHOULD be compiled code...
@Fabby always?
it just keeps printing it over and over ;)
Here you go, this is from NM's source:
		while (priv->queued_calls) {
			data = priv->queued_calls->data;
			priv->queued_calls = g_slist_remove (priv->queued_calls, data);

			_call_check_authorization_complete_with_error (data, "error creating DBUS proxy");
		}
A loop!
@Zacharee1 :p
23:46
@terdon maybe a event loop
Good thing Teensies are cheap
@Mateo what did you use to make that gif?
tehbestgifz.com @Seth
No idea what's at that address. Visit at your own risk :p
@edwardtorvalds Not that one, as far as I can tell, no. It looks like it will run as long as priv->queued_calls is defined.
@Seth lol, only the best silentcast, but then quick shrunk it in gimp
23:47
lol
I inspired that!
@Zacharee1 it's nothing ;p
@Mateo yay
from your ppa @Seth
speaking of that, you reminded me an update is waiting on me >.>
And here you go, an infinite loop from NetworkManager:
	while (TRUE) {
		switch (*value) {
		case '\0':
			return;
		case '\\':
		case '+':
		case '#':
		case ':':
			g_string_append_c (str, '+');
		default:
			g_string_append_c (str, *value);
		}
		value++;
	}
Hmm. Should I reboot to Ubuntu?
23:48
I'm procrastinating because I hate quilt.
I think I will
Goodbye for now!
heh
I'm toying with moving back to ubuntu
@terdon That's not the same as a spinloop :P
@JourneymanGeek yes you did!
Well sorta
23:49
@NathanOsman 'S still an infinite loop :)
@JourneymanGeek Just Do Itâ„¢
@terdon In fact, that loop could be written better this way:
SMB is being flaky as hell on fedora and since I'm connecting remotely anyway, I'm pondering running fedora on the back end, and sticking the Linux LiveCD Downloads (tm) to a VM
while (*(++value)) {
    switch (*value) {
    case '\\':
    case '+':
    case '#':
    case ':':
        g_string_append_c (str, '+');
    default:
        g_string_append_c (str, *value);
    }
}
@NathanOsman How does that one exit? The original seems to exit if \0 is given.
23:50
@terdon The same way.
The loop condition evaluates if *value is equal to \0.
Isn't *value a pointer?
It's a dereferenced pointer.
It returns the value of the pointer.
Ah, OK.
My C-fu is pitifu.
23:52
Actually wait.
@NathanOsman When you do your packaging do you use bzr dh-make at all?
I just found two problems with my example.
hm, can you view your own +1's on g+
But my original point still stands.
@Mateo I think so but I forget the URL.
@Seth I don't invoke it directly, no.
kos
kos
@NathanOsman *(++value) moves the pointer instead of increasing? :D
23:53
At least, I don't ever remember doing it.
urgh
Stupid Windows Update
@kos Oh that part works - but it skips the first character.
I should make it into a for() loop.
Loooooooop! Nooooooo!
kos
kos
@NathanOsman Unless I'm dead wrong ++value increases the memory location pointed by value by sizeof(type), where type is value's type, and dereferencing aftwerards will evaluate to the value at the new location (if not just segfaulting)
@NathanOsman mind going over your workflow? I'm trying to find an easy way to pull from upstream without starting over.
23:57
@kos That's correct.
@Seth The workflow for what? Putting together debian/rules?
@NathanOsman hmm, nvm. I guess you're always packaging your stuff so it's not really the same.
Oh I've packaged other people's stuff on occasion too :P
Just not very often.

« first day (1860 days earlier)      last day (3401 days later) »