Server :: Shell Scripting Command Line / Getting Error While Passing Parameter?
May 6, 2011
I am very new to shell scripting.How does one pass a command-line parameter to a shell script?for the below program
#/bin/bash
mount -t cifs -o user=ramkannan,password=Linux123@ //10.200.1.125/ramkannan /MT
cd /MT/test
date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"`
mysqldump -uroot -pram2@ employeedb > $date.sql
gzip $date.sql
I want to pass parameter for everything,i tried in google and did but iam getting error while passing parameter to all
#/bin/bash
mount -t cifs -o user=$1,password=$2 //10.200.1.125/ramkannan /MT
cd /MT/test
date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"`
mysqldump -uroot -pram2@ employeedb > $date.sql
gzip $date.sql
i was getting error while passing parameter to all.
View 2 Replies
ADVERTISEMENT
Mar 12, 2010
myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory
Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?
View 1 Replies
View Related
Jun 11, 2010
I was giving the found the following shell script. I was told it was suppose to ensure only that only one script of Test.sh can run..
However, I get it looks like it has a error when i run it... As i get Test.sh: line 9: kill: (20831) - No such process
what is going on in this script can someone explain it to me... I thought it suppose to work like a singleton for my script creating a file .run-test-sdolan. However, i don't see how or where .run-test-sdolan is create?
sdolan@staging:$ vi Test.sh
#!/bin/sh
MYDIR=`dirname $0`
CONFDIR=$HOME/
code....
View 4 Replies
View Related
Apr 9, 2010
I am trying following script can I do this or is there a way to do find and replace the replacing word is dynamic input by user
echo -n "Enter name:"
read RP_USER
sed 's/text1/$RP_USER/' /home/user/file1 > /home/user/file2
View 5 Replies
View Related
Jul 5, 2011
I am new to shell scripting..I really need ur help or guidance here..I have a text file where i have to use dos2unix command.
Now the problem is how do i pass dos2unix command in the shell scripting after it had read the text file ??
And give out the new text file.
View 3 Replies
View Related
Nov 10, 2010
On our server we have a certain directory, say /storage, that contains many large files. They are all compressed (gzip). Many of our users are not computer-savvy, and so when one of these files is needed, they will copy it to their own directory. Consequently, we have multiple terabytes of duplicate data. I'd like to enforce an alias whereby if someone tries to use cp on a file from /storage, they will instead create a symbolic link. My idea was something like:
alias cp='cp.storage'
File cp.storage:#!/bin/sh
truePath=$(readlink -f "$1")
[code]....
The conditional checks whether the file being copied begins with "/storage". The problem with this is that if someone wanted to use cp with any options on a file not in /storage, those options would be obliterated. Can someone guide me as to a good way to accomplish this? Either a way to get the options from cp into cp.storage, or another approach not using alias this way. Everyone will be using bash.
View 2 Replies
View Related
Jul 22, 2011
I have written the following script in my linux server to add users for LDAP database.But i can't able to run this.
The script is as following
#!/bin/bash
echo "Mention the username which you want to convert LDIF format"
read username
if ["$username" -e "/ldiffile/passwd"]; then
echo "Username already exists"
else
cat /etc/passwd | grep -i "$username" >> /ldiffile/passwd
fi
The output which i got :
. ldapadd.sh
Mention the username which you want to convert LDIF format
yal2361
-bash: [yal2361: command not found
please let me know where need to change and what
View 5 Replies
View Related
Feb 15, 2011
I am a bit confused with the first line while writing a shell script , if someone can please explain me the meaning of the first line " #!/bin/bash "the confusion for me is the # at the beginning , in shell scripting # means a comment. but in this case it loads the shell which the script must use,instead of commenting the line how is this possible. where is this defined , any particular file.
View 3 Replies
View Related
Aug 20, 2010
I am following an instruction on the Internet to set up a timer=1. "You can force use of the timer interrupt by using the timer=1 module arameter (or oprofile.timer=1 on the boot command line" When I type "modprobe oprofile timer=1" at the command line, I got a warning message saying that "Deprecated config file /etc/modprobe.conf" So i want to try other way by setting it at the boot command line.
View 2 Replies
View Related
Aug 4, 2010
I am writing a script to get hardware information of a particular UNIX machine. To do this, I ftp a shell script (commands to get h/w information) to the target machine and then use SSH to remote the remote script.With FTP, I can pass a password accepted as input the shell script. How can I pass the same password to SSH ? This is because I do not want the user to enter the password twice.
View 5 Replies
View Related
Aug 15, 2011
I want to connect to an FTP server from the Linux command line. The server is configured behind a proxy.
If I call:
echo $ftp_proxy
I get a result like this:
abc.def.ghi.jkl:8080
If I call:
ftp -pn $ftp_proxy
I get a unknown host error.
How can I connect to the FTP server using the Linux command line?
View 1 Replies
View Related
Jan 1, 2011
How do i find out if a particular item is a file or a folder through the terminal ls -la gives 'd' before the permissions for every folder and '-' before every fileLike i want to write a script that backup data if it is a folder and deletes if it is a file
View 2 Replies
View Related
Apr 2, 2011
how to pass an array as a command line argument in a shell script?
View 5 Replies
View Related
Jul 13, 2009
how to use QGLviewer. I want to give my program a file name as a command line argument. All of the sample programs I find have a main.cpp file like this:
Quote:
#include <QApplication>
#include "window.h"
int main(int argc, char *argv[])
[code]....
Then the Window class, which is derived from QGLViewer, does all the program's actual work. If I want access to argc and argv, for example, to open and read a file that's passed as an argument, what would handle that? Is there a built-in way to get the arg variables to the window class, or do I need to just write a loadfile function and pass them?
View 1 Replies
View Related
Jun 11, 2010
If I have the following links in HTML
Code:
<a href=lang.php?lang=cymraeg>Cymraeg</a>
<a href=lang.php?lang=english>English</a>
and lang.php has a link to page2.html, how do I pass on the value of the lang parameter from lang.php to page2.html? The value needed is the one passed in to lang.php.
View 3 Replies
View Related
Jan 21, 2011
Say, i have an imaginary std library function, which I want to call.
Code:
void std_lib_func(ObjectType *param);
Now in my c++ program, I have a main() function, and I will like to call a customized function (which will in turn call the std lib function) from the main function, as below:
Code:
int main()
{
ObjectType *aobj;
customized_func(aobj);
}
[Code]...
I tried the below but get an error that the std lib function is expecting a ObjectType* param, not aobj. How should I work this out.
Code:
void customized_func(ObjectType aobj)
View 4 Replies
View Related
Apr 26, 2010
Ive read a few books and a lot of tutorials on C but can't find this topic explained in a deliberate way.I can find bits and pieces but nothing thorough.
View 9 Replies
View Related
Apr 5, 2011
I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting.
The script looks as follows (it includes tcl commands like runFEP that you can ignore)
#!/bin/bash
for ((old=1, new=2; old<=4; old++,new++))
a1=${old}%50
a2=${new}%50
do
cat > input${new}.conf <<EOF
${a1}
code....
My question: I keep getting a syntax error when defining my two variables a1 and a2. I essentially need these variables to be
a1 = value of variable old divided by 50
a2 = value of variable new divided by 50
View 1 Replies
View Related
Jun 27, 2011
I've been doing Finite Element simulations with the Ansys software for several years now, and recently I have been allowed to use a cluster running on Linux (it's a Sun Grid Engine, or SGE). Since I am quite newbie to this thing, I have read a lot on the internet to get more familiar with the Unix language. I found some example codes which are supposed to launch Ansys and read input files, but it does not work for me. Actually, what I want to do is simple:
1- I need to use Ansys 12.1 in batch mode, with the Academic Research license (which is called "aa_r");
2- The software should then read my input file (which is an APDL command file (in case you are familiar with it..)) and save the database and results in my working directory on the server.
The software is located in the following path:
/ansys_inc/v121/ansys/bin/ansys121
My working directory:
/home/myusername/
From what I've found on the web, I have to write a shell script that calls the software and specifies the details (batch mode, license name, input file, ...). Then I have to call this script by using the command "qsub".
Script: myjob.sh
Code:
#!/bin/bash
nohup /ansys_inc/v121/ansys/bin/ansys121 -b nolist -p aa_r -j jobname -i jobname.inp -o jobname.out 2>&1 &
View 5 Replies
View Related
Feb 26, 2010
I install software called Sunflow v0.07.2 in my Ubuntu. When I try to run it,it says
"API error : JVM available memory is below 800 MB (found 728 MB only). Please make sure you launched the program with the -Xmx command line options". What is that xmx command line.What should i do to run Sunflow.
View 2 Replies
View Related
Apr 5, 2011
vi /etc/samba/smb.conf
[samba test]
comment = client
path = /opt/apps/deploy/websites
public = no
writable = yes
[Code]...
Using the bash shell script the above given samba configuration,the script should automatically add these above given entries in the /etc/samba/smb.conf.can any one help me how to edit the file add entries in the config file using shell script.
View 10 Replies
View Related
Jan 31, 2011
This started happening about 2-3 weeks ago when i noticed our backups weren't running anymore. whenever i try to run ANY type of scp command I get the following error: warning: Unrecognized configuration parameter permitlocalcommand ssh: FATAL: Illegal -o parameter "PermitLocalCommand no" lost connection
I checked the /etc/ssh/ssh_config file and there was a command PermitLocalCommand commented out, but for testing I even totally removed that line and then in scp forced the use of that file via scp -F /etc/ssh/ssh_config ......
and I still get the same error. This command is nowhere is any of my ssh config files so im at a loss here on how im supposed to fix this!! I even checked my home directory for maybe a ssh config file that might be overridding the system config but nothing.
View 1 Replies
View Related
Jul 18, 2010
delete a file on a remote server using shell scripting.
View 14 Replies
View Related
Feb 15, 2010
I have installed a puppet server and its client on Centos.Puppet server and its client is running fine and its update whatever changes made on Puppet server is updatedon its client but i am unable to execute script (Bash shell)on the client through Puppet server. So please advice a suitable class or parameter for Puppet server so that it could execute on its client
View 3 Replies
View Related
Feb 28, 2010
What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?
View 2 Replies
View Related
Apr 26, 2011
The code:
Quote:
Problem: I need a method to maintain the $i variable. In fact, actually, this variable get lost when executed. I think that an escape can preserve this variable and permit its execution inside the function, but I've no idea about.
View 3 Replies
View Related
Apr 1, 2010
I am attempting to create a script for Grid job submissions. I have most of it completed but when testing I've run into some problems.
How it works is that I have 2 wrapper files, one is the top of the script, the other the bottom, the original script imports commands for the middle.
Basically this is what is to happen:
cat script-start.sh >> workerscript.sh
echo commands >> workerscript.sh
cat script-end.sh >> workerscript.sh
workerscript.sh gets created with no problems but when it is run I get:
export: command not found
I think that the new script is not calling bash which gives the problem. I don't know how to fix the problem though because I have the shell set in the script-start.sh.
#!/bin/sh - tried /bin/bash, same result
export PROJECT=/......
export PROJSOURCE=/......
View 14 Replies
View Related
May 21, 2009
Is there a way to export a variable to parent shell in shell scripting ?
View 3 Replies
View Related
Jun 5, 2011
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....
View 10 Replies
View Related
Feb 8, 2011
I am looking for a powerful command line tool to send and receive data via socket I mean define IP , port and data other options for command to send and receive data from sender.(like a high level socket programming)
View 4 Replies
View Related