Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Output to /dev/stdout not working #12780

Closed
Synchro opened this issue Nov 27, 2014 · 11 comments
Closed

Output to /dev/stdout not working #12780

Synchro opened this issue Nov 27, 2014 · 11 comments

Comments

@Synchro
Copy link

Synchro commented Nov 27, 2014

Despite #10973 being closed, and the docs saying this works, I can't make this work. I'm running 1.9.8 on Linux. While the unit tests are linked to that ticket, they don't actually contain any tests for stdout.

These scripts should produce the same result:

var page = require('webpage').create();
page.open('http://synchro02.synchromedia.co.uk/', function() {
  page.render('g1.png');
  phantom.exit();
});

Call this one as phantomjs script2.js > g2.png

var page = require('webpage').create();
page.open('http://synchro02.synchromedia.co.uk/', function() {
  page.render('/dev/stdout');
  phantom.exit();
});

but the second one produces an empty file. Enabling debug mode produces identical output for both scripts. To avoid content issues, the page these scripts loads does not contain any javascript, just a simple HTML4 doc with a text body.

Have I missed something?

@guidoman
Copy link

I'm having the same problem with phantom 1.9.8. The following code is working on Mac OS X but not on linux (the output is empty):

page.open(address, function (status) {
        if (status !== 'success') {
            console.log('Unable to load the address!');
            phantom.exit(1);
        } else {
            window.setTimeout(function () {
                page.render('/dev/stdout', { format: 'pdf' });
                phantom.exit();
            }, 200);
        }
    });

@chompomonim
Copy link

I think you should use /process/stdout/write instead of /dev/stdout.

/dev/stdout is not in POSIX and as far as I know is used mainly in FreeBSD and MacOSX. In Linux you should use tty.

@guidoman
Copy link

Thanks for your comment, but it seems it makes no difference. Anyway, both on Linux and Mac OS X /dev/stdout is a symlink...

@flesler
Copy link

flesler commented Oct 20, 2015

+1, works locally on WIndows, fails online on AWS.
Had to roll-back to renderToBase64 for now.

@nickolaylavrinenko
Copy link

+1, faced with same problem on Ubuntu 14.04.3 LTS, on Mac OS X works fine.

@SeaOfTea
Copy link

Any updates to this? Still seems to be failing. CentOS 6.7 here.
stdout is empty

@eddydarell
Copy link

Facing the same issue on Ubuntu 16.04

@gabrielAnzaldo
Copy link

Did not work for me also in windows 7, node 6.9.1, and phantomjs-prebuilt 2.1.13.

@nicbarker
Copy link

This is still broken for me on Digital Ocean Ubuntu 16.04, works fine on my local machine (OSX El Cap)

@nicbarker
Copy link

nicbarker commented Aug 17, 2017

For anyone who finds this later, you may have had the same issue as me:

user@vps-server:~$ echo 'test' > /dev/stdout
bash: /dev/stdout: Permission denied

It turns out that using the su command to change user to something other than root actually doesn't update where /dev/stdout points (it's still pointing to a file descriptor owned by root)
See here:
https://unix.stackexchange.com/questions/38538/bash-dev-stderr-permission-denied
After sshing back into the server as the deprivileged user, /dev/stdout is now owned by the current user and phantomjs can output to it fine.

@ghost ghost removed the 1.x label Jan 10, 2018
@stale stale bot added the stale label Dec 25, 2019
@stale
Copy link

stale bot commented Dec 28, 2019

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants