What is the command to list contents of directory with Google chrome cloud shell SSH browser console? - shell

I tried ls command (and multiple others), but it's not working, how do I list the files in the directory and navigate around?
I'm attaching file to explain what I mean:

I have tried in my cloud shell and am able to list my files and navigate to the directories present. The ls command is used to list files or directories in Linux and unix. You can try using ls-a which will list the files and directories including hidden files that begin with a “.”.
If you want to display files and directories that are in the VM then you need to SSH to the respective VM instance and then try using ls -a command then it will display the respective files and directories along with hidden files. There may be a possibility that there are no directories within your cloud shell. Please refer to the images attached.

Related

How to use mget to ftp files containing specific string?

I am using mget to retrieve files from a remote server to local directory in Windows.
lcd C:\E920_1\autopkg\saveE1logafterDir\serverlog
mget /slot/ems2576/appmgr/jdedwards/e920/6210/log/jde_*.log
Now, I wish to add additional step to retrieve out of this list, only the files which contains the word "PACKAGE BUILD" inside it.
How do I accomplish it?
It's not possible. FTP protocol does not have an API to find files by their contents.
See also Search Within Files On Remote FTP Site.
So any implementation you will use will have to download all log files and search their contents locally.
In a batch file, you can use findstr command for that:
Batch file to search a keyword in all files of a directory
You may have a different way of accessing the server files. For example, if you have a (SSH) shell access, you can search the files directly on the server. But that's a completely different topic.

Uploading files from multiple directories to an SFTP site using Shell Scripting

I'm trying to upload items from multiple folder locations locally to an SFTP site. I'm using an existing shell script that I know works for uploads from a single local location, but I can't figure out how to make it work for uploads from multiple local locations.
I'm fairly new to coding and have only basic experience with batch scripting and some minor editing of existing shell scripts, so I would appreciate any help that can be given.
Here's the sample of my existing single local location upload script
open sftp://(userid):(password)#(sftp site) -hostkey="(hostkey)"
pwd
ls
lcd "(local directory)"
lls
cd (remote directory)
ls
put * -filemask=|*/ ./
exit
This has worked well for us previously, but I'm trying to clean up some of our existing scripts by combining them into one process that runs as an automated task, but I can't figure out how to chain multiple tasks like this together.
Just repeat the upload code for each location:
cd /remote/directory
lcd /local/directory1
put * -filemask=|*/ ./
lcd /local/directory2
put * -filemask=|*/ ./
Though if it's really a WinSCP script, you can use just one command like:
put -filemask=|*/ /local/directory1/* /local/directory2/* /remote/directory/
See the documentation for the put command:
put <file> [ [ <file2> ... ] <directory>/[ <newname> ] ]
...
If more parameters are specified, all except the last one specify set of files to upload. Filename can be replaced with Windows wildcard to select multiple files. To upload all files in a directory, use mask *.
The last parameter specifies target remote directory and optionally operation mask to store file(s) under different name. Target directory must end with slash. ...

I can't see pasted files in bash for windows

I'm working a programming project from school and decided to give Bash for windows a try. I downloaded the skeleton files for the project and pasted them inside the folder where my bash home folder should be. When I open the terminal and go inside the folder it shows as if there was nothing there even though I'm at the right folder. How can I get the files to be displayed?
EDIT: By now, there is actually a supported way to access these files. You have to use the \\wsl$\Legacy "network" share. For example, you could access your WSL home folder in Windows using \\wsl$\Legacy\home\<username>. Still, you should not directly access the lxss directory.
You are not supposed to touch the LXSS folder ever. The files there are use special attributes which are not understood by normal Windows applications to provide the features of a full Linux file system which NTFS on its own can't provide.
There is one hard-and-fast rule when it comes to Bash on Windows:
DO NOT, under ANY circumstances, create and/or modify Linux files
using Windows apps, tools, scripts, consoles, etc. Creating/changing
Linux files from Windows will likely result in data corruption and/or
damage your Linux environment requiring you to uninstall & reinstall
your distro! Note: Your “Linux files” are any of the files and folders
under %localappdata%\lxss – which is where the Linux filesystem –
distro and your own files – are stored on your drive
If you want to copy a file into a WSL directory which is not under /mnt, then use WSL to copy the file, i.e. use cp /mnt/c/original/folder/of/the/file.txt ~/ for example.
A more advanced alternative is starting a local SSH server in WSL and using Win-SSHFS to mount the WSL root as a drive in Windows. This way, file access will go through WSL.
Its unclear what you're asking in your question. What did you paste? Whole files? Text? Where did you paste it? Did you do the pasting into the bash window? If so was it inside a text file or did you just paste to the prompt? I'm going to assume that you pasted files to the directory that you believe that your bash home opens in i.e ~/. You may not be pasting the files into the correct directory because the default directory for bash on windows is not where you would assume it to be. you should be able to reach your desktop by typing cd /mnt/c/Users/yourUserNameHere/Desktop

How to determine full names for local Mac filename and remote filname to use SCP

I used SSH to connect to a server and navigate to the folder where I want to store some files from my Mac. I think what I need to do is use SCP to do the copy but I'm not sure exactly about the terminology in the command parameters. And so far everything I've tried gets some sort of "not found" error.
Before logging on to the server the prompt is :
Apples-MacBook-Pro-2:~ neiltayl$
After logging in and navigating to the folder I want to store things in it is :
[neiltayl#cs136 Tracer]$
I need to copy several files from the Tracer folder on my local computer to the Tracer folder on cs136 and cannot fathom the correct parts of the respective FROM and TO parts of SCP to make it work.
This is the nearest I got so far;
Apples-MacBook-Pro-2:~ neiltayl$ ls
Applications Downloads Music Tracer
Desktop Library Pictures c151
Documents Movies Public dwhelper
Apples-MacBook-Pro-2:~ neiltayl$ scp ./Tracer/*.* neiltayl#cs136.cs.iusb.edu:Tracer
neiltayl#cs136.cs.iusb.edu's password:
./Tracer/*.*: No such file or directory
The scp command is -
$ scp File1 username#someting:DIRNAME
Here File 1 is the file that you are sending over to the other computer.
DIRNAME is the path to the directory where you want the file to be stored.
In your case the command would be
scp -r Tracer neiltayl#cs136:New_Tracer
Here Tracer is the folder that contains all the files that you want to copy.

DOS ftp listing to local file

I'm trying to find a way to see if a file exists on an ftp site via DOS. I tried a get command on the file hoping that if it didn't exist it wouldn't download it to my local directory. However it seams that it still does, but it's an empty file. This doesn't work for me however because the file I'm looking for is just a empty trigger file so I can't tell the difference.
I would like to dump a listing ls of the ftp directory to a text file on my local drive and so I try
ls > listing.txt.
It creates the listing.txt file locally but it's always empty even though there are files on the ftp site.
What are my options with this?
I have used dir > listing.txt and ls > listing.txt and every time listing.txt is empty even though there are files in the directories I'm running those commands on.
Sorry if I didn't make this clear, but I'm trying to get the listing for an automated process and not simply for my visual when manually doing this.
Unless you're on FreeDOS, you're probably not using DOS. Perhaps you're using ftp.exe in the windows console? If that's the case, don't use a normal file redirect. Instead check here the syntax for ls in the standard Windows ftp client:
ls [RemoteDirectory] [LocalFile]
So you can do a ls . listing.txt to get a list of files in the current remote directory. The listing.txt file will appear in your user directory, e.g. c:\Users\user.

Resources