Obtaining path name from PID

Hi, this is a programming question that I have not been able to find an answer to, so I'm hoping someone here can help...
I am writing a C++ program that will be called by several different scripts. The program needs to log its invocations into a file and we would like to record the full path name of the calling script (e.g. /abc/defgh/script1.sh).
Rather than have the calling scripts explicitly pass their full path, I would prefer to have the called program determine it's caller's path. I know I can get the caller's PID but is there a way to translate that to the pathname? I tried opening /proc/<pid>/psinfo and looking up the 'pr_fname' member of the 'prpsinfo_t' structure but that didn't work.
Any ideas?
Thanks in advance for any help.
spc

you might want to take a look at pwdx and the proc
man page in section 4. But be aware that a the point
that you determine the working directory of the
parrent process, it might have a different cwd than
at the time your program was exec'ed.
TomTom,
thanks for the response. I did look at proc(4) and that's why I mentioned looking up the /proc/<pid>/psinfo file for each process. Unfortunately that did not give me the information I was looking for.
As for pwdx it gives the current working directory of a process - not the directory where it was run from (e.g. a script could reside at /tmp/abc.sh but have /home/t/test as its cwd). Do you know how to determine the pathname of the script?
thanks,
spc

Similar Messages

  • Obtaining file name from the file path given

    hi,
    how to obtain  file name from the file path given

    Hi bharath,
    1. PC_SPLIT_COMPLETE_FILENAME
    2.
    DATA : path LIKE pcfile-path.
    DATA : extension(5) TYPE c.
    path = filename.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    * CHECK_DOS_FORMAT =
    IMPORTING
    * DRIVE =
    extension = extension
    name = name
    * NAME_WITH_EXT =
    * PATH =
    EXCEPTIONS
    invalid_drive = 1
    invalid_extension = 2
    invalid_name = 3
    invalid_path = 4
    OTHERS = 5
    regards,
    amit m.

  • Cannot obtain disk name from vm.cfg.

    When I try to import a VM template from a server pool,it always failed at "Cannot obtain disk name from vm.cfg.".
    There are two servers in this server pool.And I have set up NFS file system for /OVS folder.
    Details for vm.cfg are:
    # Automatically generated xen config file
    name = "OVM_EL4U5_X86_PVM_4GB"
    memory = "1024"
    disk = [ 'file:/OVS/seed_pool/OVM_EL4U5_X86_PVM_4GB/system.img,hda,w', ]
    vif = [ '', ]
    bootloader="/usr/bin/pygrub"
    vcpus=1
    vfb = ["type=vnc,vncunused=1,vnclisten=0.0.0.0"]
    on_reboot = 'restart'
    on_crash = 'restart'
    If I do importing for a server pool with just one server in it,it always works well.
    Who can help me with this problem?
    Thanks very much,

    Is the NFS mounted /OVS on both servers read/write accessible to the root user? ie have you NFS exported the /OVS share with the no_root_squash option?

  • How to get the pull path name from a file upload window

    Hello everyone!
    I have encountered the following problem with the following JSP code:
    <form method="post" action="filename.jsp">
    Upload JAVA program:
    <input type=file size=20 name="fname" accept="java">
    <input type=submit value="go">
    </form>
    <%
    String s = "";
    if (request.getParameter("fname") != null)
    s = request.getParameter("fname")
    %>
    The value of s is alway the filename. However I want to get the full path in addition to the filename, so that I can read the file. Does anyone know how to get the pull name of the file?
    thanks a lot in advance,

    Dear Sir,
    thanks a lot for your reply. Please let me explain what I intended to do: I want to upload a file from the local machine and then read the content of the file. Therefore I need to the fullpath of the filename like /var/local/file.java instead of file.java. The latter is what I got.
    The problem I have with your code is that the function like "request.getServerScheme()" is not recognized. Maybe is it because I didn't install servelet package? I only installed javax package btw. Also my application runns on Tomcat server if this could give you some information. The error message I had is as follows:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:133: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    url = request.getServerScheme()
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:136: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    + ((("http".equals(request.getServerScheme()) && request.getServerPort() != 80)
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:137: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    ||("https".equals(request.getServerScheme()) && request.getServerPort() != 443))
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:139: cannot resolve symbol
    symbol : method getServletConfig ()
    location: interface javax.servlet.http.HttpServletRequest
    + "/" + request.getServletConfig().getServletName()
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:140: cannot resolve symbol
    symbol : variable path
    location: class org.apache.jsp.addExercise_jsp
    + "/" + path
    ^
    5 errors
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

  • Long file and path names

    I have a dialog window where users can choose a file, the name and path of which is then displayed. The field where this is displayed isn't big enough to hold the typical long path names found on for example Windows. I was wondering if there is a standardized way of shortening/abbreviating the full path name already written up somewhere? I want my program to be portable ... I looked at how MS Word does it on Windows, and I could write a specialized function to copy that, but then it wouldn't work on other systems that use different path conventions, and I would like to keep the generality if possible. On word they do something like this
    C:/.../final directory/filename

    Kramis wrote:
    sure, that much I understand, but I wouldn't know how to create that sort of string from an arbitrary path name of unknown format. In Windows, for example, I could take the first three characters and then ..., but that might not work globally. The questions is about parsing and converting a path name from an arbitrary system.I'd just split the path into its 'final directory name' and 'file name' (with the universal Java path seperator of (/)), and stick '...' in front of it.
    So any path such as C:/blah/blah/blah/endpath/filename or /unix/path/blah/blah/endpath/filename would become .../endpath/filename regardless of platform.

  • Get a font's file name from the font's postscript name (on Windows)

    I am trying to obtain the the font file name when the only information I have is the font's 'postscript' name. (Emphasis: the font's name is postscript and not the font).
    For example I have the following postscript name: TimesNewRomanPSMT.
    The real name that is saved in the registry is: Times New Roman (TrueType).
    Is there any way of obtaining that name from the given postscript name?
    Currently I am coding this for Windows, but it should be compatible, or at least have alternative code for MacOS

    Funny. I'm having the same problem and was about to post the exact same question
    In Photoshop, there is "app.fonts", which lets you get a font's postscript name from the font's name. This doesn't exist in After Effects.
    My only hope is that there's a way to get a font's postscript name in Visual Basic. I'll let you know if I find anything useful.

  • Obtaining the full file path specification from Flash Movie and QuickTime icons?

    How do you obtain the full file path specification from Flash
    Movie and QuickTime icons? I want the path and the file name that
    is contained in these icons. I am using a "dive" to run through the
    icons of a file, and when I come upon these two types of icons, I
    want to obtain the above information that is contained in them. I
    certainly can look in the property dialog box to get this info, but
    there are many icons in these files, and I want to generate a list
    of info based upon the various types of icons that I am processing.
    Thanks

    > How do you obtain the full file path specification from
    Flash Movie and
    > QuickTime icons? I want the path and the file name that
    is contained in
    > these
    > icons. I am using a "dive" to run through the icons of a
    file, and when I
    > come
    > upon these two types of icons, I want to obtain the
    above information that
    > is
    > contained in them. I certainly can look in the property
    dialog box to get
    > this
    > info, but there are many icons in these files, and I
    want to generate a
    > list of
    > info based upon the various types of icons that I am
    processing. Thanks
    >
    For Flash
    Trace(GetIconProperty(iconID, #pathName))
    for QuickTime
    Trace(GetIconProperty(IconID, #filename))
    For full scripting reference for each of these sprites, open
    up the
    Properties panel for each sprite and press the Help button
    that appears on
    the properties page ... or else navigate to these folders for
    the Flash and
    QT help
    C:\Program Files\Macromedia\Authorware
    7.0\xtras\FlashAsset\Help
    C:\Program Files\Macromedia\Authorware
    7.0\xtras\QuicktimeAsset\Help
    You don't want to know how many times I asked Macromedia to
    stop hiding that
    Help!
    Steve
    http://twitter.com/Stevehoward999
    Adobe Community Expert: eLearning, Mobile and Devices
    European eLearning Summit - EeLS
    Adobe-sponsored eLearning conference.
    http://www.elearningsummit.eu

  • Getting the local full path name of a file from an item File Browser

    Hi all,
    I would like to get the local full path name, of a file selected from an item 'File browser'.
    I see in wwv_flow_files the column 'name', but actually it's a kind of id like 'F1542335/myFile.gif' for example.
    What i want is the local path of this file ("C:\Documents and Settings\All Users\....\myFile.gif").
    I hope this is possible??
    Anyway, thanks all for reading.
    Ludo

    Hello, thank you for the answer.
    Please understand that I searched before posting, and not ony 15 min.
    What i mean is that the value of a File Browser in an Apex applocation is something like 'F1542335/myFile.gif', but what I need is the local path location.
    And 'F1542335/' is not the local path location, i can't use it. Or maybe there is a way to convert it in a proper path name, such as "C:\Documents and Settings\....", but I don't think so.
    So my question is : how to get the local path name of a file in Apex?
    I'll answer if I find some good things.
    Thanks
    Ludo
    Edited by: user12945874 on 06-avr.-2010 3:59

  • File name from a path

    hi ,
    there is a path "c:\abc\abc\abc\abc\abc.doc", i have to get file name from it.
    but i had to write a dynamic code which can get the file name from any given path.

    Smoke me a kipper, I'll be back before breakfast.
    SQL> var extended_filepath varchar2(128)
    SQL> exec :extended_filepath := '/this/is/a/path/to/a/file.txt'
    PL/SQL procedure successfully completed.
    SQL> select instr(:extended_filepath, '/', -1)
      2  from dual
      3  /
    INSTR(:EXTENDED_FILEPATH,'/',-1)
                                  21
    SQL> select substr(:extended_filepath, instr(:extended_filepath, '/', -1) +1)
      2  from dual
      3  /
    SUBSTR(:EXTENDED_FILEPATH,INSTR(:EXTENDED_FILEPATH,'/',-1)+1)
    file.txt
    SQL> Cheers, APC

  • Retrieve file name from full file path

    I am trying to retrieve a file name from a path (ex. c:\temp\tes.txt) using the following code, but it is given me an error of "The method split(String) in the type String is not applicable for the arguments (char).
    {code}
    String filepath = item.getName();
    String[] buf = filepath.split('/');
    String filename = buf[buf.length-1];
    {code}
    I tried to use double quote instead of single quote, but it is not returning anything.
    {code}
    String[] buf = filepath.split("/");
    {code}
    Anyone knows why? Thanks.

    How is this related to JDBC?
    Anyway, is the path separator actually a forward slash? Isn't it a backward slash?
    If you're using Apache Commons FileUpload (which I guess, the 'item.getName()' is recognizeable), then just read their FAQ: [http://commons.apache.org/fileupload/faq.html#whole-path-from-IE].

  • Reading in from File w/out path name

    Does anyone know why netbeans requires an entire path name to read from a file? I am trying to read from a file and I want the program to just look in the directory that the jar file is in to find the file to read from. I do not want the file to be IN the jar file, just inside that directory...

    As I understand it, when your code runs, it does not run relative to the folder that the jar file that contains it exists in. If you want to know where the code is running from in order to use relative path instead of absolute path, put this in your code and examine the output it generates:
    File file =new File("");
    System.out.println( file.getAbsolutePath() );
    Example: if the print out shows your code is running in:
    c:/ dir1 /dir2 / dir3
    and your file is in
    c: / dir2 /dirN / myFile.txt
    then your relative path would be:
    ../dirN/myFile.txt
    where starting from c:/ dir1 /dir2 / dir3, ../ means go one folder level "up" (to c:/ dir2 ), and dirN/ means from there, go down into the folder dirN (which would be c: / dir2 /dirN )

  • How do I obtain the names of graphic layers from a PDF?

    I want to write an applescript that will extact the layer names from a PDF imported into InDesign. However, the only layer name it returns is the separator layer "Test.indd" and not the actual layers contained in the PDF.
    The PDFs are saved from AI to include layers. Anyone have any suggestions on how to drill down into the serarator layer to get the other layer names?
    Thanks,
    Sean M.

    I don't see anything in the ID dictionary that lets you get PDF or AI layers. You might ask in the scripting forum if it can be done with a JavaScript  do script.
    You could open the PDF in AI and get the names like this, which displays the names of a selected PDF's layers from AI—I don't think you can do it in Acrobat.
    tell application "Adobe InDesign CS6"
        activate
        set myPath to file path of item link of selection of active document as alias
        tell application "Adobe Illustrator"
            open myPath
            set myLayers to name of every layer of document 1
            close document 1 saving no
        end tell
        set layerList to "Layers in current selection: " & return
         --reverse loop gets the layers from the bottom up
        repeat with i from number of items in myLayers to 1 by -1
            set x to item i of myLayers
            set layerList to layerList & x & ", "
        end repeat
        display dialog layerList
    end tell

  • Seperating file name from the path

    Hi,
    im trying to validate the file path and trying to seperate file name from the path.
    for eg.
    if the path is f:\sapfilepath\doc\ext.txt
    need to get f:\sapfilepath\doc  im looking for a dynamic way of doing this.
    your help will be appreciated.
    Regards,
    ravi.

    Hi,
    Use the function module
    SO_SPLIT_FILE_AND_PATH
    Thanks,
    Naren

  • Obtaining the name of a table from it's data

    Hello,
    i have a strange need ... i would like to obtain the name of a table from it 's data !!!!
    Thank's in advance.

    ALTER TABLE t
    ADD (table_name VARCHAR2(30));
    then
    SELECT table_name FROM T;Though, as Martin said, I don't know how you get the data if you don't know the name of the table.

  • How to obtain a URL from a path in a class' method?

    Hey everyone!
    Newbie here needing to convert the following method from a jsp page into a class for one of our applications.
    I have a method in a class which takes a path (as a string). However, I can't seem to figure out how to have java output the corresponding URL in a jsp page.
    For example, in the jsp file, I would provide something like:
    "./../../../../../../temp/gfx/" as the path.
    The "getRealPath()" method converts it nicely to a URL. However, I can't seem to figure out how to use this method within a class file. Is there a way to obtain the URL from a class' method? If so, how?
    --- old code below ---
    ServletContext application = getServletConfig().getServletContext();
    String msg = "";//#Either the IMG tag or message to be returned.
    File dir = new File(application.getRealPath(IMAGE_DIRECTORY));

    Thanks for that hint!
    Also, we're using Websphere... is there an easy way to take a partial url passed as a string and find the full path for it?
    Example:
    /images/today/
    and have it automatically converted to:
    F:/Inetpub/wwwroot/images/today/
    automatically in java?
    Or is this something where both a full system path and URL need to be passed?
    Thanks!

Maybe you are looking for

  • MeRepMeta.xml doesn't work for MAM 2.5

    I have a problem with my meRepMeta.xml. Background: Before we used WAS 6.20 and MAM 2.0. Exporting the XML file for our upload SYncBO and added to the original meRepMeta.xml worked well. At least the following code worked were Z_EPC is the name of ou

  • Outgoing Payment not allowed with witholding Tax 8.8

    I am getting error "No Matching Record Found - PCH4 ODBC-2028" while making outgoing payment in SBO 8.8 W.Tax applied on A/P invoice and showing correctly but error is coming while making payment against this invoice. What's wrong. OPS

  • Data base oracle in SAP

    Hi, The combination of all dimension id's ideally make the primary(composite) key of the fact table. it seems that there is a database restriction of 16 fields to be combined to make a joint primary key. I heard that Oracle table join relation is the

  • WDTHEME root paramater and button,command field hiding

    Dear Experts, Can any one let me know how to add WDTHEME root parameter to the application URL where i'm opening TCODE and also pls let me know how to hide buttons in the specific tcode window as shown in below snapshot. Here i'm opening SM30 transac

  • Outlook Email Reply Info

    Does anyone know if you can remove the date/time information that gets added to an email messages when replying on your iPhone. We are using Exchange 2007. Example of what I would like to remove from the message. On Jul 27, 2011, at 7:49 AM, "Smith,B