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 8707497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:53:03+00:00 2026-06-13T03:53:03+00:00

I have a problem when my script needs to communicate with a C executable.

  • 0

I have a problem when my script needs to communicate with a C executable. I cannot get the script’s full path, which I need to load and send to another process.

The script’s name is myScript

#!/home/user/git/proyect/test

hello this

is a
script

and this is the source code of the C executable

#include <stdio.h>

int main (int argc, char *argv[]){
    int count;

    printf ("Este programa fue llamado con: \"%s\".\n",argv[0]);
    if (argc > 1){
        for (count=1; count<argc; count++){
            printf("argv[%d] = %s\n", count, argv[count]);
        }
    }
    else{
        printf("The command had no other arguments.\n");
    }
    return 0;
 }

If I run myScript from terminal,

  • argv[0] shows the executable’s path (I guess that’s because it’s the info at #!).
  • argv[1] shows the first argument passed to the executable, i.e.
    • if I use ./myScript as the argument, that is what I see (the relative path)
    • if I use /home/user/git/proyect/test/scriptFolder/myScript as the argument, it shows the absolute path (which is what I need, but I don’t want to write the full path in terminal every time)

So my question is, how do I get the full path of myScript without passing its full path when calling the script?

  • 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-06-13T03:53:04+00:00Added an answer on June 13, 2026 at 3:53 am

    Your question is not very well worded so I am not sure I am answering the same question that you are asking, but you can convert “./myScript” to its full path using the realpath() function.

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

Sidebar

Related Questions

I have a problem with following script. It generates a list of places which
I have an old shell script which needs to be moved to bash. This
I have a script which needs to periodically start programs out of a array
I need help with CMD scripts. Here is my problem: I have list of
I have problem with php script. The thing is that it shows me, that
I have problem with c# script who change user AD password, when try change
I have a problem with a script and I don't know how to handle
I have a problem with this script. At first I had the <div> s
I have problem with google map Loading and making center in my java script
I have problem with python multithreaded Queues. I have this script, where producer take

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.