exec hangs up

Posted on 2010-01-07
Last Modified: 2013-11-17
i am trying to execute exec 1 > somefile.log but it just hangs and when i issue ctrl+z and ctrl+c it is not working.Please explain what does exec 1 > somefile.log 2<$l  do? and also explain why does process wont kill when i ssue ctrl+z or ctrl+c comand when it hangs.
Question by:aixtutorial
    1 Comment
    LVL 68

    Accepted Solution

    the exec command is used for redirection of file descriptors. File descriptor 1 is stdout (standard output stream).
    exec 1> /some/file redirects all standard output to the specified file instead of the terminal.
    Note - it's very important not to leave a space between "1" and ">", else the shell would try to execute "1" as a command.
    Your problems might be related to that extra space. Is there an executable "1" somewhere in your path? Normally the shell would say " 1:  not found."
    2<$I doesn't make sense at all. What is "$I"? A variable? I guess you wanted to write "&1". File descriptor 2 is stderr (the standard error output stream). "<" is used to redirect input. With 2<1 you redirect stdout to stderr, while you previously redirected stdout to a file.
    I assume you actually want to redirect stderr to the same target as stdout (somefile.log in your case). The usual notation for this is 2>&1, but the version 2<&1 will work, too.
    ctrl-c not working might be related to the extra space between ">" and "1". Omit that space and see what happens.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now