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 get this error:
[root]# sh 87.sh filesToConvert.txt
: command not found
'7.sh: line 17: syntax error near unexpected token `{
'7.sh: line 17: `processLine(){
It refers to this part:
Code:
# User define Function (UDF)
processLine(){
line="$@" # get all args
START=$(date +%s)
eval $line
#$line holds an ffmpeg command
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "It took $DIFF seconds"
echo $line
}
I am confused and new to Bash, help would be appreciated. I transferred the 87.sh to my server using filezilla. Does it need to be in ASCII mode?
Let's focus on the first question. If you wrote the script on a windows machine, then it may contain some weird character which is not managed by the shell. First try to run the dos2unix command:
I don't seem to have that command on my Fedora Core 7 server for some reason. However, I have looked through the script and there were no weird characters - is that enough?
A weird thing is if I run my script like ./87.sh i get the following:
Code:
-bash: ./87.sh: /bin/bash^M: bad interpreter: No such file or directory
But it runs fine with sh 87.sh - no idea what that means. I am doing all this as root.
That's it. It is the "carriage return" plus "newline" character used by windows instead of the "newline" used by the unix systems. Most likely you don't see that sequence of character in your editor, but it's there. Check if you can install the dos2unix utility
I use eval for the lines I parse from the text file. It runs an ffmpeg command, is there a way I can supress the output of the command I call (ffmpeg)?
If its too much work, dont worry. I will just save the stuff I need to a text file!
Well, just use redirection. If you want to completely throw away the output, redirect it to /dev/null (and eventually the standard error as well) otherwise save it to a file, for example
Code:
eval blah blah blah > /dev/null 2>&1 # stdout and stderr lost
eval blah blah blah > file.log 2>&1 # stdout and stderr into file.log
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.