# Cat command. SPod doesn't execute.

**URL:** <https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Single-Point-of-Development-SPoD\
**Created:** [January 14, 2009, 10:43pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932 "2009-01-14T22:43:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![naira](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@naira](https://techcommunity.softwareag.com/u/naira)\
**Post date:** [January 14, 2009, 10:43pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/1 "2009-01-14T22:43:52Z")

</div>

When i try to execute those lines:

COMPRESS ‘cat /transfer/arquivo \> /transfer/saida’ INTO #CMD  
CALL ‘shcmd’ #CMD

Nothing happens. The SPod doesn’t return anything.  
Is it possible to execute commands like “echo”, “vi” and “cat”, from a natural program in the natural single point?

---

<div class="post-metadata">

**Author:** ![Klaus\_Sponagel](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@Klaus\_Sponagel](https://techcommunity.softwareag.com/u/Klaus_Sponagel)\
**Post date:** [January 15, 2009, 5:22pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/2 "2009-01-15T17:22:39Z")

</div>

Hi Naira  
You can execute shell commands even if the program runs under SPoD. There is just no terminal the shell can print its output. Try following:

```auto

CMD := 'pwd > /tmp/aaaa'      
CALL 'shcmd' CMD 
```

and check if the file /tmp/aaaa has been created and contains the pwd output.

---

<div class="post-metadata">

**Author:** ![naira](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@naira](https://techcommunity.softwareag.com/u/naira)\
**Post date:** [January 16, 2009, 1:54am UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/3 "2009-01-16T01:54:22Z")

</div>

Hi Klaus,

this command works. But I still need to edit a file in unix directory.

To see it, I’m using work file and “display” command. It works fine. But I’m still trying to find out how to edit it.

Thank you.

---

<div class="post-metadata">

**Author:** ![Klaus\_Sponagel](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@Klaus\_Sponagel](https://techcommunity.softwareag.com/u/Klaus_Sponagel)\
**Post date:** [January 16, 2009, 2:36pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/4 "2009-01-16T14:36:36Z")

</div>

Hi Naira  
There is no possibility I’m afraid.  
If you run under SPoD you do not have a terminal on the server.  
The Natural IO, which usually is routed to the terminal, is intercepted by SPoD and sent back to the client for displaying. But it is not possible to intercept the data the shell routes directly to the terminal.

May be it is an option to upload/download the file with Entire Connection:

```auto

0040 DEFINE WORK FILE 1 '/tmp/aaaa' TYPE 'ASCII'
0050 DEFINE WORK FILE 2 TYPE 'TRANSFER'
0060 INPUT 'a'
0070 SET CONTROL '+'
0080 READ WORK FILE 1 REC
0090 DOWNLOAD PC 3 REC
0100 END-WORK
```

Now edit the file on PC and upload the data.

An other approach could be to process the file editing using a Natural program

```auto

0050 DEFINE WORK FILE 1 '/tmp/aaaa' TYPE 'ASCII'
0060 READ WORK FILE 1 REC(I)
0070 ADD 1 TO I
0080 END-WORK
0090 CLOSE WORK 1
0100 /* input processing
0110 FOR I 1 100
0120 WRITE WORK 1 REC(I)
0130 END-FOR  
```

Cheers  
Klaus

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [January 16, 2009, 4:10pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/5 "2009-01-16T16:10:09Z")

</div>

> [@naira](#):
>
> When i try to execute those lines:
> 
> COMPRESS ‘cat /transfer/arquivo \> /transfer/saida’ INTO #CMD  
> CALL ‘shcmd’ #CMD
> 
> Nothing happens. The SPod doesn’t return anything.

What’s the content of RET(“SHCMD”) after your call?  
Maybe the natural-process doesn’t have the right to write into directory /transfer. To find this out, please redirect the Error-Output of your command into a separate file. Like this:

```auto
COMPRESS 'cat /transfer/arquivo > /transfer/saida 2>/tmp/error.log' INTO #CMD
CALL 'shcmd' #CMD
```

What’s the content of /tmp/error.log afterwards?

> [@](#):
>
> Is it possible to execute commands like “echo”, “vi” and “cat”, from a natural program in the natural single point?

echo and cat should work. vi doesn’t work, because it’s an interactive program. But you can use a “batch editor” like sed instead. Example:

```auto
sed 's/old/new/g' /tmp/input.txt > /tmp/output.txt
```

Explanation: Replace “old” in file input.txt with “new” and write the output to output.txt. Of couse sed can do much more things than replacing …

---

<div class="post-metadata">

**Author:** ![naira](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@naira](https://techcommunity.softwareag.com/u/naira)\
**Post date:** [January 20, 2009, 7:27pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/6 "2009-01-20T19:27:53Z")

</div>

Hi Mathias,

I tried this command:

COMPRESS ‘cat /transfer/arquivo 2\>/tmp/error.log’ INTO #CMD

and the error.log was like:

cat: write error: Input/output error

Until now, I solve it using sysmain. The file is imported to natural, edited and sent back to directory. But isn’t an elegant solution.

Any more help will be welcome.

Thank you all.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [January 22, 2009, 12:31pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/7 "2009-01-22T12:31:34Z")

</div>

> [@naira](#):
>
> COMPRESS ‘cat /transfer/arquivo 2\>/tmp/error.log’ INTO #CMD
> 
> and the error.log was like:
> 
> cat: write error: Input/output error

That proofs: Natural executes the command “cat”, but the command fails.

I guess you will get the same error, if you execute your command on the Linux/Unix command line… If so, it’s not Natural’s error.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:51pm UTC](https://techcommunity.softwareag.com/t/cat-command-spod-doesnt-execute/79932/8 "2021-04-02T14:51:21Z")

</div>


