When you edit the wireless settings you need to make sure that "Available to all users" and "Connect automatically" checkboxes are enabled and it will be available to everyone automatically. Early versions of Network Manager for some systems did not have "Available to all users" enabled by default (yours might be one of those systems) and the symptoms you describe are exactly the behavior that is supposed to happen with configuration setting. That was a confusing default setting for most people, so now the default is to have it enabled (at least it is for Ubuntu).
You can also check from the command line what devices and connections are managed by NetworkManager:
$ nmcli dev
DEVICE TYPE STATE
wlan1 802-11-wireless connected
eth1 802-3-ethernet connected
$ nmcli con
NAME UUID TYPE TIMESTAMP-REAL
Yak n Yeti b4e05828-e57e-4399-96aa-6cd988ee4975 802-11-wireless Thu 27 Dec 2012 07:30:19 AM PST
The settings are stored in /etc/NetworkManager/system-connections/
and you'll want to make sure that autoconnect=true
and that either the users you want are listed permissions=user:whoever:root:;
or the equivalent of "Available to all users" which is permissions=[];
[connection]
id=Yak n Yeti
uuid=b4e05828-e57e-4399-96aa-6cd988ee4975
type=802-11-wireless
permissions=user:whoever:;
autoconnect=false
timestamp=1355439451
[802-11-wireless]
ssid=Yak n Yeti
mode=infrastructure
mac-address=24:77:05:FF:97:BC
security=802-11-wireless-security
[802-11-wireless-security]
key-mgmt=wpa-psk
wep-key-flags=1
psk-flags=1
leap-password-flags=1
[ipv4]
method=auto
[ipv6]
method=auto
Here's the short and sweet - a heredoc
is basically a file streamed to a file-descriptor.
Most people don't denote the 0<<descriptor
and so you get it on <&0 stdin. ssh
passes stdin
to its invoked process so if you feed it a heredoc
it will pass through the input to the invoked remote shell.
The one very special quality about heredocs
is the difference between a \"'quoted
and unquoted heredoc LIMITER.
So, <<'THIS'
differs from <<THIS.
When you do not quote the LIMITER,
the contents of the here-document are evaluated for ${shell:+expansion}
. Once one ${shell:+expansion}
pass is completed, there is very little else to distinguish a here-document from any other file fed as <~/input
.
For example:
cat <<\QUOTED >~/file
$(echo "This is ${NOT:-} expanded.")
#END
QUOTED
cat <~/file
> $(echo "This is ${NOT:-} expanded.")
> #END
But...
cat <<UNQUOTED >~/file
$(echo "This is ${NOT:-} expanded.")
#END
UNQUOTED
cat <~/file
> This is expanded.
> #END
You keep using the bash <<< herestring
with cat.
I don't know exactly how the herestring
works but I'm willing to bet cat's
already involved. So cat
concatenates its <&0stdin
with its stdout>&1
. That's all it does. So you're unnecessarily complicating <<STDIN
when you <<< cat
it.
This can be a real problem if cat
winds up consuming an input stream which you did not intend it to consume. Run just % cat
at your terminal and it will look like nothing is happening because a terminal's stdin
and stdout
are the same file - your $(tty)
. But when they differ, cat
combines them anyway and that can get pretty messy if you didn't mean it to happen.
It looks to me like some \'quotes
are skipping an expansion when $(date)
is $expanded
. Then possibly the : null shell builtin
is invoked and |piped
to the next unquoted command after ssh
which would be cat >> report.fail
which should generate nothing at all in that file. So cat
is >>appending /dev/null
to report.fail
, for as long as it can stand it, I guess. Or, more likely, for as long as exit
allows ssh
to carry-on proxying the null stream.
Also, have you checked to see if you've got a literal $TMP
in your current working directory? I do see ENDSSH
at the bottom which looks like a heredoc LIMITER
to me so I believe either this is not the entire script or it has been edited by mistake. It would make sense if it were the body of a heredoc to use \$TMP,
but as is I think nc
will first >truncate
then write its stdout
to a file named $TMP.
Then again, I guess you rm
it anyway, so maybe you just didn't notice.
And because you're rm
ing $TMP
you may not have realized anyone would be asking this question:
How does $(mktemp)
work for you without the filename.xxx
argument?
UPDATE I looked closer at your output and definitely >/tmp/tmp.GJ1knZF5Jn
means $(mktemp)
is working - even the \$TMP
part. So you've just taught me that I only need to specify mktemp .xxx
if I specify a filename at all. Thank you.
Still I think there is a heredoc at the top somewhere? It could be there is not and \\
is only an attempt to deal with a side-effect of the echo \$TMP <<<herestring,
but I dunno... Interesting.
I don't know if I've got this completely right because I don't know where all of these variables come from. But, this is close to how I would do this:
(which actually renders the last two questions irrelevant anyway)
_ssh() ( ssh "$1"@"$2" 'printf %s, `cat` >> '"$3"
) <<-PARAMS
"$lastSourceIP"
"$lastDestinationIP"
"$sourceFqdn"
"$fqdn"
"$port" "
"ConnectivityNA"
"NA"
"NA"
"Pas"
"$(date)"
PARAMS
nc -z -v -n $lastDestinationIP $port |\
grep -q "succeeded" && suffix=txt
_ssh user host report.${suffix:-fail}
unset suffix
?ENDSSH?
Note: the "$quotes"
in the above are for printf's
benefit on the other side of the ssh
process - not for anything else. Those "quotes"
remain as is even after all of the above PARAMS
are evaluated.
There are some things going on up there that I've covered before. For instance the func() ( scope )
I like to think was covered ok here. The ${parameter:-expansion}
was also covered there, but also demonstrated pretty well here and here. I've gotten into some of the weird heredoc stuff here, here, and here. Probably there are others - I guess I like messing up my shell or something.
In this case, though, using the function and the heredoc as I have, cat
can't get stuck. PARAMS
is sent over as stdin
and cat
will quit when it reaches an EOF
(or CTRL-D
) so as soon as it consumes PARAMS
it's going to stop everytime. This is especially important if you are running this in a heredoc
which is also on <&0
because PARAMS
will stand in the way of cat
eating your script mid-execute.
Anyway, hopefully that helps. If I've missed anything, don't hesitate to ask.
Best Answer
Here is something I wrote now that run on each line of
batch-file.txt
and run youtube-dl on it.If there is no connection to the web site you trying to download from it will loop until connection restored (you should probably need to add some timeout on it since it will not stop.)
I used
curl
with expected200
status code since if this don't work you probably won't be able to download.The content of
batch-file.txt
is the same as before.Running the script:
Edit:
Just found this in the README.md and tested it working .
This for case each line is a playlist and not separate video.
This will download only new videos each time you run so if you add
--download-archive archive.txt
to the script above in./youtube-dl --download-archive archive.txt "$line"
So if it's start again it will go over all the playlist but will only start download from where it's stops.