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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:35:22+00:00 2026-06-11T18:35:22+00:00

%cat fact #!/usr/bin/env escript %% -*- erlang -*- %%! -smp enable -sname factorial -mnesia

  • 0

%cat fact

#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
    try
        N = list_to_integer(String),
        F = fac(N),
        io:format("factorial ~w = ~w\n", [N,F])
    catch
        _:_ ->
            usage()
    end;
main(_) ->
    usage().

usage() ->
    io:format("usage: factorial integer\n"),
    halt(1).

fac(0) -> 1;
fac(N) -> N * fac(N-1).

%./fact “5”

escript: no such file or directory: ‘./fact’

%whereis escript

escript: /usr/bin/escript

%pacman -Qi erlang

name   : erlang
version  : R14B04-1

Why doesnot escript run “fact” ?


On my Archlinux box, escript still doesnot work !

%cat hello.erl 
main(_) -> io:fwrite("~p~n", "hello,world!").

%escript hello.erl 
escript: no such file or directory: 'hello.erl'

%whereis escript 
escript: /usr/bin/escript

%ls -l /usr/bin/escript
lrwxrwxrwx 1 root root 25 12月 18 17:37 /usr/bin/escript -> ../lib/erlang/bin/escript*

%/usr/lib/erlang/bin/escript hello.erl 
escript: no such file or directory: 'hello.erl'

%strace -f -F -o aaa.txt /usr/lib/erlang/bin/escript hello.erl 
escript: no such file or directory: 'hello.erl
%cat aaa.txt
execve("/usr/lib/erlang/bin/escript", ["/usr/lib/erlang/bin/escript", "hello.erl"], [/* 40 vars */]) = 0
...
open("hello.erl", O_RDONLY|O_LARGEFILE) = 3
...
execve("/usr/lib/erlang/bin/erl", ["/usr/lib/erlang/bin/erl", "+B", "-boot", "start_clean", "-noshell", "-run", "escript", "start", "-extra", "hello.erl"], [/* 40 vars */]) = 0.
...
stat64("hello.erl", 0xb5a44d90)   = -1 ENOENT (No such file or directory)
open("hello.erl", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
......

Why does it use “stat64” instead of “stat” ? I am using 32 bits system.

%uname -a
Linux myarch 3.1.5-1-ARCH #1 SMP PREEMPT Sun Dec 11 06:26:14 UTC 2011 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux
%erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.8.5

Sincerely!


%ls
fact*
%escript fact "5" 
escript: no such file or directory: 'fact'
%escript fact 5  
escript: no such file or directory: 'fact

%ls -l /usr/bin/escript 
lrwxrwxrwx 1 root root 25 10月 15 03:24 /usr/bin/escript -> ../lib/erlang/bin/escript*

Strange problem ?

  • 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-11T18:35:23+00:00Added an answer on June 11, 2026 at 6:35 pm

    The reason is VERY simple. Because the following line is in ~/.erlang:

    file:set_cwd("/media/D/www/qachina/db/doc/erlang")
    

    so that escript will change the current directory once executed. The escript works great after removing that line.

    Best Regards!

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

Sidebar

Related Questions

...besides the fact that Rscript is invoked with #!/usr/bin/env Rscript and littler with #!/usr/local/bin/r
/bin/ksh -c cat $PMSourceFileDir/RT/TgtFiles/$OutputFileStrPerfHdr $PMSourceFileDir/RT/TgtFiles/$OutputFileStrPerfCSV | unix2dos -437 > $PMRootDir/RT/Temp/$OutputFileStrPerfCSV I work in IBM
Say I had a fact such as: bigger(cat,mouse). If I wanted to describe this
cat main.c #include <stdio.h> #include <stdlib.h> #include <linux/ext2_fs.h> int main(int argc, char** argv) {
I am always annoyed by this fact: $ cat foo.py def foo(flag): if flag:
cat test.txt #this is comment line 1 line 2 #this is comment at line
% CAT(2,A,B) is the same as [A,B]. % CAT(1,A,B) is the same as [A;B].
$ cat file.txt one two three $ cat file.txt | sed s/one/1/ 1 two
$ cat Const.java public class Const { String Const(String hello) { return hello; }
When I submit #top_cat , the firebug console says ok because of the debug

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.