redirection problems..

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

redirection problems..

#1 Post by sc0ttman »

SOLVED: see last post

....


I tried Google.. now here.. I have this code, which works for me in bash-4.2.0:

Code: Select all

cvlc "$FILE" vlc://quit &>>"$LOGFILE" &
The above runs VLC, outputting everything to $LOGFILE, and that is all run in the background, as the script it's inside then moves on to do stuff with the cvlc process..

Anyway... The code does not work (reportedly) in bash 3 .. apparently this does (a space before >>):

Code: Select all

cvlc "$FILE" vlc://quit & >>"$LOGFILE" &
If I change &>> to just >>, then everything works fine, except the actual redirection that I want!

..

The code is loaded from within a func.. That func is not loaded as a background process.. But often that func is itself loaded inside another func which IS run as a background process ... As is, it all works for me..

I tried a few things, until it got messy and things got worse.. Any guidance on what's going on here would be greatly appreciated..

The relevant post is here, and originally reported a posts back from there: http://www.murga-linux.com/puppy/viewto ... 378#687378
Last edited by sc0ttman on Tue 26 Feb 2013, 13:10, edited 1 time in total.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

Are you really wanting to *append* to the logfile? If not, then using '&>' would be correct and certainly works with bash-3.x

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#3 Post by sc0ttman »

I am indeed wanting to append.. But it's not essential.. Before this code I posted, the logfile is created with the actual VLC command and options printed at the top...

I am just hoping to make it work on both BASH versions, as well as I can..

I'd rather not have to have separate bits for different bash versions, so might drop the initial stuff added to the log file, and not append, as you suggest..
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#4 Post by amigo »

I just checked and this works with bash-3.x:

Code: Select all

cvlc "$FILE" vlc://quit 2>&1 1>>"$LOGFILE" &

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#5 Post by sc0ttman »

amigo wrote:I just checked and this works with bash-3.x:

Code: Select all

cvlc "$FILE" vlc://quit 2>&1 1>>"$LOGFILE" &
But it breaks the actual logging - with the above code, nothing is added to the logfile (in bash4 at least) .. I need logging to work for both bash 3 and bash 4..
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#6 Post by amigo »

Try this:

Code: Select all

cvlc "$FILE" vlc://quit 2>&1 |tee "$LOGFILE" &

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#7 Post by sc0ttman »

amigo wrote:Try this:

Code: Select all

cvlc "$FILE" vlc://quit 2>&1 |tee "$LOGFILE" &
Thanks again for the suggestion amigo.. Unfortunately, while this does fix the logging (somewhat, not including the first part, but thats fine..) but it breaks vlc-gtk, so that all cvlc processes go AWOL, and cannot be stopped, next'd, prev'd, etc.. they all play over each other, not replacing each other as before..

Damn, this is harder than I thought (I've also been trying my own stuff as well obv).. I might have to re-think how vlc-gtk all gets to that cvlc cmd in the first place, or get a totally new method of logging... I hope not..
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#8 Post by amigo »

Is vlc-gtk a gtkdialog app, by chance?? If so, it should be no surprise that things go weird at times. Back up and try another tactic, if so. Or, maybe it needed to be backgrounded this way:

Code: Select all

cvlc "$FILE" vlc://quit 2>&1 & |tee "$LOGFILE"

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#9 Post by technosaurus »

I've been meaning to patch gtkdialog to use the more portable async gio wrappers for popen. If there is any way you could boil it down to a simplified version, I'll take a look at it.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#10 Post by sc0ttman »

SOLVED!

This is what works for me, using 2>>$LOGIFLE, not 1>> ...

Code: Select all

cvlc "$FILE" vlc://quit 2>&1 2>>"$LOGFILE" &
The above code works in bash 3 and 4.. Thanks amigo!! :D
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

Post Reply