0

I'm working with IRAF, based on SPP, kind of a mix between Fortran and C. I'm looking for a way of referring to a string content when using ls. For example, I can type ls *hola* if I want to list every file containing the word hola in my directory. Supose I have an string called id whose content is the world hola. How could I refer to the content in id? I'm looking for some sort of ls id (I know that construction won't work) which returns the same result as in ls *hola*.

Thank you in advance.

EDIT: SPP is somehow hidden on the Internet but here you have a reference manual https://www.mn.uio.no/astro/english/services/it/help/visualization/iraf/SPPManual.pdf although I haven't found any information there related to this topic.

Ed Morton
  • 188,023
  • 17
  • 78
  • 185
Pablo
  • 87
  • 5
  • Please improve your question. [edit](https://stackoverflow.com/posts/66294736/edit) it to add some URL related to SPP. https://spp.org/ is not a programming language! Also mention what operating system you are using (Linux, Windows, MacOSX, FreeBSD, ...)? – Basile Starynkevitch Feb 20 '21 at 18:25

2 Answers2

1

Using the C side of your SPP thing, if you have access to the C headers, the simple is use something like

#include <stdio.h>
#include <stdlib.h>

    int main(void)
    {
        char* command = "ls";
        char* args = "*.c";
        char line[80];
        sprintf( line, " %s %s\n", command, args );
        system(line);
    };

But in C you have dirent.h where you can find the functions that does this things. Try man opendir on your machine

OPENDIR(3)                                    Linux Programmer's Manual                                    OPENDIR(3)

NAME
       opendir, fdopendir - open a directory

SYNOPSIS
       #include <sys/types.h>
       #include <dirent.h>

       DIR *opendir(const char *name);
       DIR *fdopendir(int fd);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       fdopendir():
           Since glibc 2.10:
               _POSIX_C_SOURCE >= 200809L
           Before glibc 2.10:
               _GNU_SOURCE

DESCRIPTION
       The  opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to
       the directory stream.  The stream is positioned at the first entry in the directory.

       The fdopendir() function is like opendir(), but returns a directory stream for the directory  referred  to  by
       the open file descriptor fd.  After a successful call to fdopendir(), fd is used internally by the implementa‐
       tion, and should not otherwise be used by the application.

RETURN VALUE
...
arfneto
  • 1,227
  • 1
  • 6
  • 13
  • If one is using ifort, then there are also fortran tools for that... if that strikes one's fancy. – Holmz Feb 22 '21 at 08:21
0

First, I would recommend not to use SPP (and IRAF) at all. IRAF is out of official maintainance now, and writing new code for a deprecated software is probably a dead end.

Concerning your question: SPP comes with a function fntopnb() for IRAF style access to filename templates. They are documented at pages 101ff. of the SPP manual. A usage example can be found in the sources of pkg/system/files.x of IRAF:

call salloc (fname, SZ_FNAME, TY_CHAR)

list = fntopnb ("*id*", NO)
while (fntgfnb (list, Memc[fname], SZ_FNAME) != EOF) {
    call printf ("%s\n")
    call pargstr (Memc[fname])
}

call fntclsb (list)
olebole
  • 521
  • 4
  • 17