Programming :: Possible To Assist In Programming Shell Scripts?
May 17, 2010
Is it possible to assist in the programming Shell Scripts
Job:
To send a message to the email,All orders written in Terminal or ssh
example : ls , pwd , cat , and other
I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
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....
Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?
Example:
Code:
>>> import subprocess >>> help(subprocess) ... [pages of stuff to read] ...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.
I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.
I have a shell script that I would like to log to stdout and also to a file.....much like using tee. I would like to, instead of calling the script and piping to tee...i would like for the script to tee itself.
I need to push out a file to a bunch of linux and solaris boxes so I was hoping to use a script to automate the process with scp (or something else / better) - how can I batchmode scp so that it will do this? I should mention the servers do have keys set up so I do not have to authenticate manually or through something like an expect script...
However when I do the exact above command on unix prompt (refer below) after setting values for all variables, it is not giving sed garbled error message. May I know what should I do to make it work inside the script as well?
$ cat init_refresh$CLONE_DB.ora | sed "s/$ORIG_LOG_ARCHIVE_FORMAT/$SRC_LOG_ARCHIVE_FORMAT/g" > $LOG_DIR/init_refresh1$CLONE_DB.ora $
I'm trying to write a toy linux shell. For starters this is what I'm trying to do:
1. Start a new process with fork.
2. Execute a program in the new process with execl().
3. Redirect the output from the new process from STDOUT to another file descriptor, using dup2(2).
4. In the parent process, read the output from the child process and write it to the screen.
Creating a new process and executing a program in it is no problems, the problem is that I can't seem to capture the output from it in the parent process.
Code: Select allapt-get install icedove-l10n-hu apt-get install rar apt-get install ... ... y press key or other language is other key. hungarian key is: i
english after apt-get install in gnome-terminal: (y)es or (n)o hungarian after apt-get install in gnome-terminal: (i)gen or (n)em
How to yes or no automatically in all languages? Not manual, not 'Y'/'I' or 'N'/'N' keydown.
I would like use this script my fresh installed Debian 7.1. I would like run this install.sh when Debian is installed for my all softwares when i would like use.
I'm running into a problem when I try to set a variable to an awk output in c-shell. Right now my command is Code: set STR_MSG_TYPE = `awk -F{ '/msg_type/ {print $2}' <filename> | tr -d }'/''*' ` I then run echo to see what the output is and it returns blank, however, when I run the same awk command from the command line, I get an actual output of "MT-715". Am I setting my variable incorrectly? I do something similar using the date command to set a STR_DATE variable earlier in the code and it works fine and I use the same syntax.
I want to spawn a GDB session from bash script and keep it working to interact it from outside. But when I start it in background (with '&' sigil).
Code: gdb -x gdb_script.txt ./a.out < gdb_pipe.fifo & It executes passed script and terminates by itself (I do not pass any data or signals to it)
Code: Breakpoint 33, main (argc=1, argv=0xbffff0f4) at main.c:53 ---Type <return> to continue, or q <return> to quit---53 read_main_config(); (gdb) quit
A debugging session is active. Inferior 1 [process 5957] will be killed. Quit anyway? (y or n) [answered Y; input not from terminal] What can I do to make it alive?
I am aware this has probably been covered hundreds of times, so apologies if so. I am fairly new to the linux scripting scene, so again apologies if what I'm saying seems pretty odd and makes no sense. I am attempting to write a script for some Linux Fedora test servers I have set up. For me to change which domain I have this set to point to, I would have previously changed the HOSTS and profile files manually, however I managed to make a script which changes these easily with the use of one command to launch the script.The problem I'm having is getting it to use the "export" command. I am aware this would have to be launched in the parent shell rather than the child and so I made a seperate script which has "export SIP_DOMAIN="test.blah.net" in it and had the first script "source" it. This doesn't work and I've probably done something somewhere that is incredibly stupid.
I am very new to shell script, and my requirement is --
1. open the apache access log, use "cut" and "grep" to find the numbers. 2.put the result in a file 3.then compare the same result with day before result 4. send the result via e-mail.
I am trying to do some shell programs. I tried some sites regarding the while loop, they give the structure as: Code: while [ n1 -lt 500 ] do echo $((n1+100)) done
But the below code also worked for me: Code: while ((n1 > 500)) do echo $((n1+100)) done By using (( )) I could use while, for. But the documentations didnt follow this way. I mainly use this for datastructure programming.
When I start my shell it hangs (somehow, it's being put to sleep) and I always have to control-cancel the shell before using it. Anyone know of a way to figure out what gets started on a typical shell session?
I have some simple shell scripts that perform backups and I was wondering how do I add logging? More specifically writing to a log file if any part of the script fails. An example of what my shell scripts look like:
what we are trying to do is, to let the customer click a button in the web browser, and then the web server to call a shell script to do the work. The output from the stdout && stderr of the script should be displayed in the web browser once finished or timeout, along with the exit code of the script.
The shell script is however not on the web server, but on another app server. So to call this script from the web server as the identity 'tomcat':
Code: $ sh appuser@app-server:$appbin/app-script
The .ssh/id_rsa.pub thing is done, and we have no problem doing this in the command line so far.
Our loaded ex-colleage has left us the webpages (jsp) with code like these:
Code: <%@ include file="jsp_functions.jsp" %> <% String cmd = "sh $appbin/app-script"; ExecResult r = new ExecResult();
I want to know how can I debug shell scripts.Many a times I found while installing a software or a package some where some link to some file or dependency is broken.Some one suggested me use of -vx in the beginning I want to know what are the other methods to debug shell scripts.
Usability? Home: you use bash. Work, school, vacation, seminar: you're stuck using zsh or tcsh (or Drush in Drupal).
Function: Without giving errors, quietly cross-checks a non-shell command for its equivalent in the running shell and executes that command, properly-syntaxed.
Name: Well, as the word "imperative" in rudimentary linguistics is a synonym for "command," I thought of an acronym derived from the terms SHell Imperatives Translator. But this morning, I re-thought the lavatorial acronym. Considering it was a "container" of "hooks" that had the potential to operate much like a stripped-down cron or Ubuntu hook bundle, a more polite term for it would be "tacklebox".