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
# 8  
Old 05-05-2010
Quote:
Originally Posted by Corona688
Try ls and see what the filename actually is...
ok. the file name is "ss1.txt"
so i type
Code:
./ss1.txt

and i get this now.

"./ss1.txt: ./ss1.txt: cannot execute binary file"
# 9  
Old 05-05-2010
Quote:
Originally Posted by pantelis
ok. the file name is "ss1.txt"
so i type
Code:
./ss1.txt

and i get this now.

"./ss1.txt: ./ss1.txt: cannot execute binary file"
But you said the script was called ss1. So what is ss1.txt, and why are you running it?

A slight modification to Corona's request:

Code:
ls -l ss1*

# 10  
Old 05-05-2010
Quote:
Originally Posted by scottn
But you said the script was called ss1. So what is ss1.txt, and why are you running it?

A modification to Corona's request:

Code:
ls -l ss1*

it is called ss1 but it is a text file. so i have to type "ss1.txt " to run it.
but i get that binary error
# 11  
Old 05-05-2010
Quote:
Originally Posted by pantelis
it is called ss1. but it is a text file. so i have to type "ss1.txt " to run it.
but i get that binary error
This is (presumably) UNIX or Linux you are using?

If your script is called ss1, you run it as ss1 - regardless of whether it's text or binary.

File extensions in UNIX are notional, not like Windows, with file associations, and all.

You didn't answer the ls -l question!
# 12  
Old 05-05-2010
Quote:
Originally Posted by scottn
This is (presumably) UNIX or Linux you are using?

If your script is called ss1, you run it as ss1 - regardless of whether it's text or binary.

File extensions in UNIX are notional, not like Windows, with file associations, and all.

You didn't answer the ls -l question!
when i run
Code:
ls -l ss1*

i get this:
"ss1.txt"
and im on linux.
# 13  
Old 05-05-2010
Quote:
Originally Posted by pantelis
it is called ss1 but it is a text file. so i have to type "ss1.txt " to run it.
Linux doesn't have file extensions as you understand them(or text versus binary files either -- they're all just bytes as far as the OS is concerned.) The ".txt" is part of the filename proper, it won't fill in any sort of extension for you. And what the name is doesn't matter one bit -- you could make it ".exe", ".sh", ".omgwtfbbq", or leave off the extension entirely and Linux won't care. As long as the file's set executable it will try to run it. When it does so, it checks if the beginning of the file is the magic "#!" that means a script, or an ELF header for compiled programs.

So, "ss1.txt", the whole thing, is the file name.
# 14  
Old 05-05-2010
Quote:
Originally Posted by pantelis
when i run
Code:
ls -l ss1*

i get this:
"ss1.txt"
and im on linux.
I'm a bit lost here Smilie

So, where is your "hello world" script?

Let's start again, because this isn't getting us anywhere Smilie

Show the full output of these commands:
Code:
ls -l ss1*
file ss1*
cat ss1*

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