help needed with script that gets a filename as argument (with an if/else statement)
Hi,
I am trying to create a script just to study BASH scripting, but I have some problems.
I need to create a script that gets a filename as an argument. The script should behave as follows:
• If the given file name already exists, inform the user and quit.
• If the given file name does not exist, create an empty file by that name and inform the user.
How can I use the value of an argument as a filename? Example:
The argument for a process is 999. I would like the output of the process to be placed in a file called 999. I have tried using $$1, but that only assigns a unigue number.
thanks
JP (1 Reply)
Can someone please help me with this SHELL script?
I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1.
Here is a start but I have no clue how to... (3 Replies)
I know this is a simple matter, but I'm new to this.
I have a shell script that calls a sed script from within it. I want the output of the shell script to be based on the input file I pass as an argument to the original script. In other words...
./script.sh file.txt
(script.sh calls sed... (2 Replies)
If ($argv == “-debug”) then
Echo “in loop”
Endif
But this is not working. If I modify this code and remove “-“, then it works.
Similarly I am getting problem using grep command also
Grep “-debug” Filename
Can someone please help me on how to resolve these... (1 Reply)
Hi,
i have files which contains list of csv file names
say temp.txt contains below like data
Dns_bangalore_08172011.093033.1139.csv
Dns_bangalore_08172011.093133.1139.csv
now i want to insert some string before .csv in the filename
say i want to insert string _sim1 beofre .csv... (3 Replies)
Hi,I have a script which is given below :#!/bin/bash. ini_script.shdb2 connect to $DB_NAME user $DB2_UID using $DB2_PASSWORDfor file in `ls -1 ./sql/ddw/`do echo "Executing the file $file" echo db2 -tvf $filedonedb2 quiti want this script to accept directorie's names present in... (1 Reply)
I am trying to create an Expect script that does the following:
1) Telnets to an IP address and logs in with user ID and Password
2) Issue a CLI command to the server that will output data of which I am particularly interested in a DS1 clock 'Slips' value. I want to be able to keep issuing... (0 Replies)
Hi I need a script with an if statement that goes.
I need it to search through all files within a directory with the extension .test if it finds the string '71502FSC1206' then do
sed 's/71502FSC1206/\n&/g' > send.test
If it finds the string '715MCH' or '715JAC' then I need it to move the... (1 Reply)
Hello,
A python beginner question on passing filename thru argument. My code is:
#!/usr/bin/python
import sys, getopt
import os
def main(argv):
try:
opts, args = getopt.getopt(sys.argv,"hi:o:ce", )
except getopt.GetoptError:
usage()
print("Usage: %s... (6 Replies)
Discussion started by: yifangt
6 Replies
LEARN ABOUT DEBIAN
dbus-uuidgen
dbus-uuidgen(1) General Commands Manual dbus-uuidgen(1)NAME
dbus-uuidgen - Utility to generate UUIDs
SYNOPSIS
dbus-uuidgen [--version] [--ensure[=FILENAME]] [--get[=FILENAME]]
DESCRIPTION
The dbus-uuidgen command generates or reads a universally unique ID.
Note that the D-Bus UUID has no relationship to RFC 4122 and does not generate UUIDs compatible with that spec. Many systems have a sepa-
rate command for that (often called "uuidgen").
See http://www.freedesktop.org/software/dbus/ for more information about D-Bus.
The primary usage of dbus-uuidgen is to run in the post-install script of a D-Bus package like this:
dbus-uuidgen --ensure
This will ensure that /var/lib/dbus/machine-id exists and has the uuid in it. It won't overwrite an existing uuid, since this id should
remain fixed for a single machine until the next reboot at least.
The important properties of the machine UUID are that 1) it remains unchanged until the next reboot and 2) it is different for any two run-
ning instances of the OS kernel. That is, if two processes see the same UUID, they should also see the same shared memory, UNIX domain
sockets, local X displays, localhost.localdomain resolution, process IDs, and so forth.
If you run dbus-uuidgen with no options it just prints a new uuid made up out of thin air.
If you run it with --get, it prints the machine UUID by default, or the UUID in the specified file if you specify a file.
If you try to change an existing machine-id on a running system, it will probably result in bad things happening. Don't try to change this
file. Also, don't make it the same on two different systems; it needs to be different anytime there are two different kernels running.
The UUID should be different on two different virtual machines, because there are two different kernels.
OPTIONS
The following options are supported:
--get[=FILENAME]
If a filename is not given, defaults to localstatedir/lib/dbus/machine-id (localstatedir is usually /var). If this file exists and
is valid, the uuid in the file is printed on stdout. Otherwise, the command exits with a nonzero status.
--ensure[=FILENAME]
If a filename is not given, defaults to localstatedir/lib/dbus/machine-id (localstatedir is usually /var). If this file exists then
it will be validated, and a failure code returned if it contains the wrong thing. If the file does not exist, it will be created
with a new uuid in it. On success, prints no output.
--version
Print the version of dbus-uuidgen
AUTHOR
See http://www.freedesktop.org/software/dbus/doc/AUTHORS
BUGS
Please send bug reports to the D-Bus mailing list or bug tracker, see http://www.freedesktop.org/software/dbus/
dbus-uuidgen(1)