Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i use the csh shell at work. you can either log on to servers locally or to the NFS mount. is is important to know which you are mounted to when executing scripts. csh is the only shell that lets me know which high availability server i am currently on.
before i write a shell script to complete a task, i have to type sh or bash at the prompt, hit enter and then configure the script. then when i am done, hit control -d to get out the bash or sh shell.
is there a way to run sh or bash scripts from the csh command line - i have tried typing this at the csh command line: /bin/sh (or ./bin/bash)
while [ 1 ]; do ps auxwww | grep fire | wc -l ; done ... etc, but it does not work.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
I'm sorry, I don't quite get what you're asking -- first off, you would not "cd /bin/sh" (/bin/sh is an executable file, not a directory). Many installations do not have the current directory in the user's PATH environment, so, to execute a shell program ("script"), you can cd to the directory where it resides then enter "./shell_prog_name" to execute that program. If your shell program has the "#!/bin/sh" as the first line of the program, it will be executed by the appropriate shell.
You can normally execute any executable program (irrespective of what the source code may be) from the C-Shell command prompt; the example you've given is a Shell while loop (which will not, I'm sure you've discovered, execute in C-Shell). You can,
Code:
% /bin/sh (this enters the Bourne Shell from the C-Shell)
# while ... (your while)
^D (exit the Bourne shell; back to the C-Shell)
%
so i am not at work right now, but you are explaining that i should be able to go
cd /bin/sh ; while [ 1 ] ; do ps auxwww | grep fire | wc -l ; done
right from the csh command line - that would be acceptable.
No -- the technique given was to run a bash script, not to execute bash commands. If you want to be able to execute bash commands like that you need to do as you wrote "before i write a shell script to complete a task, i have to type sh or bash at the prompt, hit enter and then configure the script. then when i am done, hit control -d to get out the bash or sh shell". But there may be some misunderstanding; "writing a shell script" is creating a file with shell commands in it and then running the file as a script, thus running the commands in it. When you write "configure the script", do you mean entering commands at the prompt or creating a file with shell commands in it?
yeah, please don't work to hard on this. just figured i would give it a shot.
alot of times when i am running a job that does not exit cleanly, i will log in to another shell and type this in directly into the command line -
while [ 1 ] do ; ps auxwww | grep somejobUncleanExit | wc -l ; date; sleep 5; done
this will return a one or a zero - which lets me know, within 5 seconds when the job is done.
i can't run this from the csh shell - i have to type in "sh" first then hit <enter>, then type in the command.
so this is not a text file that I run ./fromTheDirectory, it is just something that i type into the command line.
i do this at least 40 times a night. i don't have permissions to save anything to many of these drives.
typing the sh, switching to the bash shell is not a big hassle - I was just wondering if there was a way i could do this from the csh shell.
sure i cold just use the sh shell - but for some reason the bourne shell 'pwd' does not distinguish from a local or an NFS mounted drive. the csh shell does - and running a NFS job on a local machine is bad. so what i have is a bunch of sh shells open with the csh paths as xterm --title's, spitting out 1's or 0's. it is cluttered, but i guess that it is going to have to due, because there does not seem to be any way to type in and execute a sh command at the csh prompt.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.