Newbie needs help with simple script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Newbie needs help with simple script
# 8  
Old 02-27-2006
and I have to chmod ugo+x the file then I can execute it like ./script right?


I cant understand why it wont work.
# 9  
Old 02-27-2006
Quote:
Originally Posted by shizizzle
ok i changed that,

it is saying ":bad interpreter: No such file or directory" when i try to execute the script.

I have tried /bin/bash, /usr/bin/bash, /bin/sh, /usr/bin/sh

nothing works.
This kind of thing can happen when you create/edit a file on MS Windows and ftp the file over to UNIX with out eliminating the ^M (carriage return) characters.

Try this:
Code:
ex - yourscript.sh
1,$s/^M//
wq

You enter the ^M by hitting Control-V and then Control-M.

You can confirm that these characters exist in your file by dumping the file through od.
Code:
od -x yourscript.sh

The last line of the output will have 0d0a values if you need to strip the carriage returns.
# 10  
Old 02-27-2006
Yeah, that should work. Don't know what to tell you. Smilie
# 11  
Old 02-27-2006
Just an idea - make sure your /bin/bash is executable and NOT some kind of the 'script' itself.
# 12  
Old 02-27-2006
Quote:
Originally Posted by tmarikle
This kind of thing can happen when you create/edit a file on MS Windows and ftp the file over to UNIX with out eliminating the ^M (carriage return) characters.

Try this:
Code:
ex - yourscript.sh
1,$s/^M//
wq

You enter the ^M by hitting Control-V and then Control-M.

You can confirm that these characters exist in your file by dumping the file through od.
Code:
od -x yourscript.sh

The last line of the output will have 0d0a values if you need to strip the carriage returns.
Thank you so much, this worked. Once again, thank you very much, I couldnt of done it without yours guys help.
# 13  
Old 03-21-2006
To debug your script, the shell has a useful feature, it is:set -xv. You can place this entry anywhere in the script to provide useful debug information when you run the script. I usually comment out the line after a debug-cycle, but you can change the -xv to a +xv to accomplish the same behavior.

Good luck!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

2. Shell Programming and Scripting

Shell script newbie, what is problem with my script?

Hello, Ubuntu server 11.10 can anybody help what is problem with my shell script? #!/bin/bash #script to find out currently logged on user is root or not. if ] then echo "You are super" else echo "You are awesome!" fi When I run script, I get following output ./uid: line 3: I... (4 Replies)
Discussion started by: kaustubh
4 Replies

3. Shell Programming and Scripting

please help newbie with script

hi!i am musician and have very little knowledge about shell here's my script #!/bin/bash for (( ; ; )) do wget some wikipedia article here --output-document=- > /dev/audio done so it downloads random wikipedia page (forum doesnt let me post link so i wrote some wikipedia article here... (6 Replies)
Discussion started by: karlhungus
6 Replies

4. UNIX for Dummies Questions & Answers

Need help with simple Linux commands - NEWBIE here!

Hey guys, I need help with simple unix commands. I'm a newbie to Unix and don't know these commands. Any help is appreciated. 1. Logon to Linux. 2. Create a directory "Unix" under your home directory. Command(s): …………………………………………. 3. Create four... (1 Reply)
Discussion started by: loverangerguy
1 Replies

5. OS X (Apple)

Newbie Backup Script

Hello All, I have attempted to write my first complex (to me) backup script. I am offering it to any and all who may find it useful but would like to refine it as well. I'm using it to backup a Mac OSX Lion Server to a USB Raid5. The script is actually comprised of a daily and a weekly script... (3 Replies)
Discussion started by: dbol
3 Replies

6. Shell Programming and Scripting

simple problem for a newbie

I am trying to find a way to display just sudoers, passwd and shadow files without the extensions.. Thank you for any suggestions ls -lrt /etc | egrep 'sudoers|passwd|group|shadow' -r-------- 1 root root 1338 Oct 31 2006 shadow.sav -r-------- 1 root root 5191... (4 Replies)
Discussion started by: delphys
4 Replies

7. Shell Programming and Scripting

Shell Script Help -I'm a newbie

Can someone help me write this shell script? I am completely new to shell and as a fun task my uncle has challenged me a problem (out of all other people). Basically, all he wants me to do is to create backup file in a folder that is named “disables.” This is what he said: create a shell script... (0 Replies)
Discussion started by: hotcutiepie05
0 Replies

8. Shell Programming and Scripting

Newbie problem with simple script to create a directory

script is: dirname= "$(date +%b%d)_$(date +%H%M)" mkdir $dirname should create a directory named Nov4_ Instead I get the following returned: root@dchs-pint-001:/=>./test1 ./test1: Nov04_0736: not found. Usage: mkdir Directory ... root@dchs-pint-001:/=> TOO easy, but what am I... (2 Replies)
Discussion started by: gwfay
2 Replies

9. Programming

newbie to unix programming in C, needed a few simple prgs on these functions!

Hi all, I am a newbie to unix programming using C.. So i would like to have a few simple C programs to start off with.. I wanted programs on learning , abort,kill and raise,alarm and pause,I would also like to know how to use the vfork() in a prg It would be really great if i can have... (1 Reply)
Discussion started by: wrapster
1 Replies

10. UNIX for Dummies Questions & Answers

Simple newbie grep question

How come grep testfile1 won't find anything in testfile1 (even though the characters sd are there in great quantity), but grep '' testfile1 will find plenty? Do the single quotes prevent the shell from interpreting the testfile1 is interpreted as: grep *test whether or not characters sd exist*... (5 Replies)
Discussion started by: doubleminus
5 Replies
Login or Register to Ask a Question