/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Using PIPE " | " in exec

Hello, I am trying to pass some text off to an application via the PIPE function in terminal (Unix). The way I am trying to do it is like so:

exec(‘echo -n “sometext” | someapp’);

However, the text doesn’t seem to get piped to the app..

Any ideas?

Thanks in advanced!
Kyle

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 21.2008 — Could be a [url=http://www.php.net/manual/en/features.safe-mode.php]safe_mode[/url] issue. As per the [url=http://www.php.net/manual/en/function.exec.php]exec() page[/url]:
[B]
[CENTER][SIZE="3"]Warning[/SIZE][/CENTER]
[/B]

With safe mode enabled, the command string is escaped with escapeshellcmd(). Thus, [FONT="Courier New"]echo y | echo x[/FONT] becomes [FONT="Courier New"]echo y | echo x[/FONT].[/quote]
Copy linkTweet thisAlerts:
@Kyleva2204authorFeb 21.2008 — I am not using safe mode, however.. I think that something is getting piped becaues if nothing is getting piped it asks for something.. but its not asking, so something is getting piped just not what I told it. the actual thing is

$query = 'echo -n "' . $thepass .'" | hdiutil attach -stdinpass ~/Desktop/encrypted.dmg';

echo $query . "n";

exec($query);

Thanks
Copy linkTweet thisAlerts:
@Kyleva2204authorFeb 21.2008 — Figured it out, for some reason it didnt work with the -n and the -stdinpass.. IDK why, anywho thanks for anyone that was htinking about it ?
×

Success!

Help @Kyleva2204 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...