Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 884779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:48:02+00:00 2026-05-15T12:48:02+00:00

as the problem states.. when i do exec(ls -ltr > output.txt 2>&1,$result,$status); its different

  • 0

as the problem states..
when i do

exec("ls -ltr  > output.txt 2>&1",$result,$status);

its different from the normal output. An extra column gets added. something like

-rw-r--r-- 1 apache   apache    211 Jul  1 15:52 withoutsudo.txt
-rw-r--r-- 1 apache   apache      0 Jul  1 15:53 withsudo.txt

where as when executed from the command prompt its like

-rw-r--r-- 1 apache   apache    211 2010-07-01 15:52 withoutsudo.txt
-rw-r--r-- 1 apache   apache    274 2010-07-01 15:53 withsudo.txt
-rw-r--r-- 1 apache   apache    346 2010-07-01 15:55 sudominusu.txt
-rw-r--r-- 1 apache   apache    414 2010-07-01 15:58 sudominusu.txt

See the difference. So in the first output , my usual awk ‘{print $8}’ fails.
I was facing the same problem with cron. But solved it by calling

./$HOME/.bashrc

in the script. But not happening using php. If somehow i can “tell” php to “exec” from the usual environment. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:48:03+00:00Added an answer on May 15, 2026 at 12:48 pm

    I guess you are only interested in the file names and you want to sort with reverse time.
    Try this:

    ls -tr1 > output.txt 2>&1

    You’ll get a list with only the file names, so you don’t need awk at all.

    Another solution is to specify the time format with “–time-style iso”. Have a look at the man page

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well here's my problem I have three tables; regions, countries, states. Countries can be
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: Given a list of strings, find the substring which, if subtracted from the
I need to read the output from ffmpeg in order to even try the
I'm having a bit of a problem with moving specific data from one server
Problem 19-2 in Lisp by Winston and Horn states, In depth-first search, all of
I've got a problem publishing my current Project status. Mapping: <publishers> <xmllogger /><!-- Log
I have a problem analogous to the one described here: Prevent fork() from copying
In my program I'm executing given command and getting result (log, and exit status).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.