problem writing a simple c shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem writing a simple c shell script
# 15  
Old 05-05-2010
Code:
ls -l ss1*

-rwx------ 1 adr1g09 ad_csug 46 May  5 18:54 ss1.txt

file ss1*

ss1.txt:

cat ss1*

ÿþ#!/bin/csh
echo hello

# 16  
Old 05-05-2010
Quote:
Originally Posted by pantelis
ÿþ#!/bin/csh
echo hello
[/code]
Are you editing these scripts in Notepad or something? There's garbage before the #!/bin/csh that's preventing it from working, I suspect it's a Unicode byte-order indicator inserted by a Windows program. Try running 'nano ss1.txt' in the shell to get a proper editor inside Linux.

[edit] In fact, delete the file and create a whole new one with nano. You'll probably have problems with carriage returns until you make a new file.

Last edited by Corona688; 05-05-2010 at 03:28 PM..
# 17  
Old 05-05-2010
Quote:
Originally Posted by pantelis
Code:
ls -l ss1*

-rwx------ 1 adr1g09 ad_csug 46 May  5 18:54 ss1.txt

file ss1*

ss1.txt:

cat ss1*

ÿþ#!/bin/csh
echo hello

Great Smilie (see the Corona reply)
# 18  
Old 05-05-2010
If this question is related to this post:

https://www.unix.com/shell-programmin...#post302418817

it is a homework question IMHO.
# 19  
Old 05-05-2010
Quote:
Originally Posted by Corona688
Are you editing these scripts in Notepad or something? There's garbage before the #!/bin/csh that's preventing it from working, I suspect it's a Unicode byte-order indicator inserted by a Windows program. Try running 'nano ss1.txt' in the shell to get a proper editor inside Linux.

[edit] In fact, delete the file and create a whole new one with nano. You'll probably have problems with carriage returns until you make a new file.
yeah im writing them in notepad. what should i use?
and i tried nano ss1.txt
i removed the garbage, saved the file, and now it runs, but
"echo hello" does not execute
# 20  
Old 05-05-2010
Quote:
Originally Posted by Franklin52
If this question is related to this post:

https://www.unix.com/shell-programmin...#post302418817

it is a homework question IMHO.
Agreed. Closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script (simple problem)

I want to find and replace string from files present in one directory. user will input the string to be searched and to replace . Here is my program but Not working echo "Enter Old domain name:" read old echo "Enter New domain name:" read new grep -rl '$old' /var/www/ | xargs sed -i... (4 Replies)
Discussion started by: sunny2802
4 Replies

2. Shell Programming and Scripting

writing a simple script to get total number of cpus/cores in server

Hi, I am very new to scripting and I wanted to write a unix shell script which can give me, 1)number of cpu's in a box 2)number of cores per cpu 3)total number of cores in abox (ie multiplying 1&2) I am also trying to figure out how to check if hyper-threading is enabled in the... (8 Replies)
Discussion started by: steven12
8 Replies

3. Shell Programming and Scripting

Problem with writing into a file through shell script

Hi all, I have a shell script which I use to login to the server from the client and then from the server I run a bunch of other scripts to complete my task. I am having problems with the script below- #!/bin/bash while read line do connections=`echo $line | cut -d " " -f 1` period=`echo... (3 Replies)
Discussion started by: joydeep4u
3 Replies

4. Shell Programming and Scripting

Help with writing simple bash script

I want to write a bash script to: 1. Send an email from localhost to an external gmail account. (gmail then automatically forwards the message back to a pop account on the same server. 2. Script waits 3 minutes then checks to see if the email arrived, and if not, it sends an email to... (9 Replies)
Discussion started by: sallyanne
9 Replies

5. Shell Programming and Scripting

newbie: writing ksh shell problem

my default profile is using ksh, I tried to write a simple scripts and I had issues, below is my scripts: $ more if_num.ksh USAGE="usage: if_num.ksh" print -n "Enter two numbers: " read x y if ((x=y)) then print "You entered the same number twice." when I tried to executed the... (6 Replies)
Discussion started by: matthew00
6 Replies

6. Shell Programming and Scripting

Problem with IF - CAT - GREP in simple shell script

Hi all, Here is my requirement I have to search 'ORA' word in out.log file,if it is present then i need to send that file (out.log) content to some mail id.If 'ORA' word is not in that file then i need to send 'load succesful' message to some mail id. The below the shell script is not... (5 Replies)
Discussion started by: mak_boop
5 Replies

7. Shell Programming and Scripting

one simple shell script problem

Hi everyone, I am facing to one shell script problem, which is as following Write a shell script that: Takes a number of arguments. For each argument, print out all files in the current directory that contain this substring in their name. I know I need to use grep for the second... (7 Replies)
Discussion started by: shaloovia
7 Replies

8. UNIX for Dummies Questions & Answers

HELP! writing simple shell script

how would i write a shell script to show the number of lines in which int variable appears in a c++ program. (3 Replies)
Discussion started by: deadleg
3 Replies

9. UNIX for Dummies Questions & Answers

simple shell script problem

hi all. i have a little problem. im basically reading input from the user from the keyboard into the variable "phonenumber". I want to do a little error check to check if the user doesnt enter anything in for the value phonenumber. i had this: read phonenumber if then ..... else ........ (2 Replies)
Discussion started by: djt0506
2 Replies

10. UNIX for Dummies Questions & Answers

Need help writing simple script

I'm trying to write a simple unix script that will delete files after 30 days of being created. I've never done this before but conceptually it sounds easy. Here is what I'm trying to do: Get System Date Get File Date If (sysdate-filedate>30days) rm file All of these files are contained... (1 Reply)
Discussion started by: tamdoankc
1 Replies
Login or Register to Ask a Question