# ls command in Remote Server

**URL:** <https://community.unix.com/t/ls-command-in-remote-server/199151>\
**Category:** Shell Programming and Scripting\
**Created:** [May 30, 2008, 9:20pm UTC](https://community.unix.com/t/ls-command-in-remote-server/199151 "2008-05-30T21:20:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasuarjula](https://community.unix.com/letter_avatar/vasuarjula/32/6_449c533f586939b6e5f246632a46421f.png) [@vasuarjula](https://community.unix.com/u/vasuarjula)\
**Post date:** [May 30, 2008, 9:20pm UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/1 "2008-05-30T21:20:58Z")

</div>

Unix Box: IBM AIX  
Shell : K-Shell

When i logged into a remote server through FTP, and tried to find only required month file by typing `ls -ltr *200805`, the output is "ls remotefile localfile". I coudnt understand this.  
What is want is get into the remote server and get the count of required files like "ls -ltr \*200805 | wc -l". This is working in my machine but not on remote directory. how can i do this. Advance appreciations for the help

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [May 31, 2008, 8:52am UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/2 "2008-05-31T08:52:35Z")

</div>

The ls command option in ftp is not the same as ls(1). It supports a very limited set of options. Read the ftp man page for more information.

---

<div class="post-metadata">

**Author:** ![danmero](https://community.unix.com/letter_avatar/danmero/32/6_449c533f586939b6e5f246632a46421f.png) [@danmero](https://community.unix.com/u/danmero)\
**Post date:** [May 31, 2008, 9:51am UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/3 "2008-05-31T09:51:19Z")

</div>

Run the command via ssh:

```nohighlight
ssh host "ls -ltr *200805 | wc -l" 

```

---

<div class="post-metadata">

**Author:** ![matrixmadhan](https://community.unix.com/letter_avatar/matrixmadhan/32/6_449c533f586939b6e5f246632a46421f.png) [@matrixmadhan](https://community.unix.com/u/matrixmadhan)\
**Post date:** [May 31, 2008, 10:08am UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/4 "2008-05-31T10:08:38Z")

</div>

you might have to check mdtm utility in Net::FTP module.

But again, it will not work in ftp service hosted in windows machine

---

<div class="post-metadata">

**Author:** ![matrixmadhan](https://community.unix.com/letter_avatar/matrixmadhan/32/6_449c533f586939b6e5f246632a46421f.png) [@matrixmadhan](https://community.unix.com/u/matrixmadhan)\
**Post date:** [May 31, 2008, 10:10am UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/5 "2008-05-31T10:10:10Z")

</div>

> [@danmero](#):
>
> Run the command via ssh:
> 
> ```plaintext
> ssh host "ls -ltr *200805 | wc -l" 
> 
> ```

With OP's case I think its not possible, where access to specified directory is possible only through ftp login.

Had it been ssh login, there shouldn't be any problem at all.

---

<div class="post-metadata">

**Author:** ![vasuarjula](https://community.unix.com/letter_avatar/vasuarjula/32/6_449c533f586939b6e5f246632a46421f.png) [@vasuarjula](https://community.unix.com/u/vasuarjula)\
**Post date:** [June 2, 2008, 2:26pm UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/6 "2008-06-02T14:26:39Z")

</div>

"ssh host ls -ltr \*200805\* | wc -l"

When i type this, it says invalid command.  
ssh is not working.  
What is this ssh  
and what should i put in place of host. (remote machine name or local machine name)

---

<div class="post-metadata">

**Author:** ![danmero](https://community.unix.com/letter_avatar/danmero/32/6_449c533f586939b6e5f246632a46421f.png) [@danmero](https://community.unix.com/u/danmero)\
**Post date:** [June 8, 2008, 11:11am UTC](https://community.unix.com/t/ls-command-in-remote-server/199151/7 "2008-06-08T11:11:08Z")

</div>

What about:

```plaintext
ssh host "ls -ltr *200805* | wc -l"

```

[Secure Shell - Wikipedia, the free encyclopedia](http://en.wikipedia.org/wiki/Secure_Shell)

> [@vasuarjula](#):
>
> and what should i put in place of host. (remote machine name or local machine name)

remote host.
