Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to save and execute a C shell scrip?

Posted on 2011-10-27
2
Medium Priority
?
320 Views
Last Modified: 2012-06-27
I have a simple Cshell script as follows:

#! /bin/csh -f
set SourceDir = /home/milligram/mnt
set DestDir_IOS = Myvideos/IOS
chdir $SourceDir

foreach directory (`ls`)

test -d "$SourceDir/$directory" && echo "$SourceDir/$directory"

end

How do I save and execute the above script to a file in ubuntu and execute it via a terminal session?

where should I store the script?

0
Comment
Question by:wademi
2 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 2000 total points
ID: 37042645
Open your favorite editor and paste the code into the file.

For example use vi

vi script.csh

The press i to bring it to insert mode and paste the code

then hit Esc to bring to command mode and do
:x (enter)

File is saved.
Now issue command
chmod +x script.csh

And run it

./script.csh
0
 
LVL 81

Expert Comment

by:arnold
ID: 37042658
To redirect the output to a file you would use
./script.csh > filename_where_results_will_be_stored
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question